Dzień dobry zwracam się z pytaniem jak skonfigurować wejście sygnałowe w procesorze PIC30F6012A, potrzebuje wysterować odpowiednią konfiguracje wyjść po podaniu 5v na wejście RB0, już nie wiem co robię nie tak ale nie potrafię skonfigurować tego pinu jako input. Poniżej wklejam aktualny program narazie ma tylko podstawowe funkcje mrugania jednej diody i po pojawieniu się sygnału na RB0 powinien zapalić drugą(jestem dość początkujący w programowaniu). z góry dziękuje za podpowiedzi co robię źle.
#pragma config FOSFPR = LPRC // Oscillator (Internal Low-Power RC (No change to Primary Osc Mode bits))
#pragma config FCKSMEN = CSW_FSCM_OFF // Clock Switching and Monitor (Sw Disabled, Mon Disabled)
// FWDT
#pragma config FWPSB = WDTPSB_16 // WDT Prescaler B (1:16)
#pragma config FWPSA = WDTPSA_512 // WDT Prescaler A (1:512)
#pragma config WDT = WDT_OFF // Watchdog Timer (Disabled)
// FBORPOR
#pragma config FPWRT = PWRT_OFF // POR Timer Value (Timer Disabled)
#pragma config BODENV = NONE // Brown Out Voltage (Reserved)
#pragma config BOREN = PBOR_ON // PBOR Enable (Enabled)
#pragma config MCLRE = MCLR_EN // Master Clear Enable (Enabled)
// FBS
#pragma config BWRP = WR_PROTECT_BOOT_OFF// Boot Segment Program Memory Write Protect (Boot Segment Program Memory may be written)
#pragma config BSS = NO_BOOT_CODE // Boot Segment Program Flash Memory Code Protection (No Boot Segment)
#pragma config EBS = NO_BOOT_EEPROM // Boot Segment Data EEPROM Protection (No Boot EEPROM)
#pragma config RBS = NO_BOOT_RAM // Boot Segment Data RAM Protection (No Boot RAM)
// FSS
#pragma config SWRP = WR_PROT_SEC_OFF // Secure Segment Program Write Protect (Disabled)
#pragma config SSS = NO_SEC_CODE // Secure Segment Program Flash Memory Code Protection (No Secure Segment)
#pragma config ESS = NO_SEC_EEPROM // Secure Segment Data EEPROM Protection (No Segment Data EEPROM)
#pragma config RSS = NO_SEC_RAM // Secure Segment Data RAM Protection (No Secure RAM)
// FGS
#pragma config GWRP = GWRP_OFF // General Code Segment Write Protect (Disabled)
#pragma config GCP = GSS_OFF // General Segment Code Protection (Disabled)
// FICD
#pragma config ICS = ICS_PGD // Comm Channel Select (Use PGC/EMUC and PGD/EMUD)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include "xc.h"
void Delay(unsigned int time){
unsigned int i, j;
for (i=0; i<time; i++);
for (j=0; j<10000; j++);
}
int main(void) {
TRISF = 0b00000000;
TRISB = 0b0000000000000001;
while(1){
PORTFbits.RF4 =1;
Delay(1000);
PORTFbits.RF4 =0;
Delay(1000);
PORTBbits.RB15 =1;
Delay(1000);
PORTBbits.RB15 =0;
Delay(1000);
if (PORTBbits.RB0 == 1) {
PORTFbits.RF5 = 1;
}
else PORTFbits.RF5 = 0;
}
return 0;
}
#pragma config FOSFPR = LPRC // Oscillator (Internal Low-Power RC (No change to Primary Osc Mode bits))
#pragma config FCKSMEN = CSW_FSCM_OFF // Clock Switching and Monitor (Sw Disabled, Mon Disabled)
// FWDT
#pragma config FWPSB = WDTPSB_16 // WDT Prescaler B (1:16)
#pragma config FWPSA = WDTPSA_512 // WDT Prescaler A (1:512)
#pragma config WDT = WDT_OFF // Watchdog Timer (Disabled)
// FBORPOR
#pragma config FPWRT = PWRT_OFF // POR Timer Value (Timer Disabled)
#pragma config BODENV = NONE // Brown Out Voltage (Reserved)
#pragma config BOREN = PBOR_ON // PBOR Enable (Enabled)
#pragma config MCLRE = MCLR_EN // Master Clear Enable (Enabled)
// FBS
#pragma config BWRP = WR_PROTECT_BOOT_OFF// Boot Segment Program Memory Write Protect (Boot Segment Program Memory may be written)
#pragma config BSS = NO_BOOT_CODE // Boot Segment Program Flash Memory Code Protection (No Boot Segment)
#pragma config EBS = NO_BOOT_EEPROM // Boot Segment Data EEPROM Protection (No Boot EEPROM)
#pragma config RBS = NO_BOOT_RAM // Boot Segment Data RAM Protection (No Boot RAM)
// FSS
#pragma config SWRP = WR_PROT_SEC_OFF // Secure Segment Program Write Protect (Disabled)
#pragma config SSS = NO_SEC_CODE // Secure Segment Program Flash Memory Code Protection (No Secure Segment)
#pragma config ESS = NO_SEC_EEPROM // Secure Segment Data EEPROM Protection (No Segment Data EEPROM)
#pragma config RSS = NO_SEC_RAM // Secure Segment Data RAM Protection (No Secure RAM)
// FGS
#pragma config GWRP = GWRP_OFF // General Code Segment Write Protect (Disabled)
#pragma config GCP = GSS_OFF // General Segment Code Protection (Disabled)
// FICD
#pragma config ICS = ICS_PGD // Comm Channel Select (Use PGC/EMUC and PGD/EMUD)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include "xc.h"
void Delay(unsigned int time){
unsigned int i, j;
for (i=0; i<time; i++);
for (j=0; j<10000; j++);
}
int main(void) {
TRISF = 0b00000000;
TRISB = 0b0000000000000001;
while(1){
PORTFbits.RF4 =1;
Delay(1000);
PORTFbits.RF4 =0;
Delay(1000);
PORTBbits.RB15 =1;
Delay(1000);
PORTBbits.RB15 =0;
Delay(1000);
if (PORTBbits.RB0 == 1) {
PORTFbits.RF5 = 1;
}
else PORTFbits.RF5 = 0;
}
return 0;
}