JerryR
Joined: 07 Feb 2008 Posts: 167
|
PIC18F87J60 no UART2 interrupt |
Posted: Mon Oct 03, 2016 9:34 am |
|
|
I can't seem to get UART on my PIC18F87J60 to generate an interrupt. PCWH version 5.021. TTL signals at good at RX2 (RG2) at 9600 baud
*h
Code: |
#use rs232(baud=9600,UART2,parity=N,bits=8,ERRORS,stream=PC)
|
interrupt code:
Code: |
//RS232 Com PC Interrupt
#INT_RDA2
void RDA_isr(void)
{
Char_In= fgetc(PC);
if ((Char_In >= 0x61) && (Char_In <= 0x7A)) //if lower case, then...
Char_In = Char_In - 0x20; //change to upper case
Char_In_Buffer = TRUE;
}
|
Main:
Code: |
//==============================================================================
void main()
{
char Temp_In;
//Initialize external devices
lcd_init();
init_ext_eeprom();
Can_Edit= FALSE; //can't edit parameters on PC screen to start
Last_Menu= 0; //set both last and current menu to 0
Menu= 0;
output_low(Fan2_Drive); // Set CCP2 output low
output_low(Fan1_Drive); // Set CCP1 output low
setup_ccp1(CCP_PWM); // Configure CCP1 as Fan1 drive
setup_ccp2(CCP_PWM); // Configure CCP2 as Fan2 drive
setup_timer_2(T2_DIV_BY_16, Max_Duty, 1); // 500 Hz
set_timer1(0);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
setup_ccp3(CCP_CAPTURE_RE);
//Interrupt enables:
//clear_interrupt(INT_CCP3); // Clear the CCP1 interrupt flag before we enable CCP1 interrupts, so that we don't get an unwanted
//enable_interrupts(INT_CCP3);
enable_interrupts(INT_RDA2); //enable PC communications
enable_interrupts(GLOBAL); //enable global interrupts
//PC communication initialization
Char_In_Buffer= FALSE;
index= 0;
Got_Param_Num = FALSE;
Menu= 0;
for (index= 0 ; index <= 4 ; index++)
Char_Buffer[index]= 0;
//Restore Operational values on boot-up
//write_ext_eeprom(2,0x33);
Temp_In = read_ext_eeprom(2);
delay_us(1);
//ee_backup();
//ee_restore();
While(TRUE)
{
Output_Control();
if (Char_In_Buffer)
{
Char_In_Buffer= FALSE;
Get_PC_Message();
}
}
}
|
Anything look wrong here?
Thanks! |
|