|
|
View previous topic :: View next topic |
Author |
Message |
javi.ar
Joined: 17 Feb 2006 Posts: 59 Location: Argentina
|
18F4525 rs232 interrupt question |
Posted: Tue Sep 04, 2007 10:09 pm |
|
|
Hi everyone ...
I have this code just to get data from rs232
Code: | #device adc=8
#FUSES NOWDT, WDT128, HS, NOPROTECT, IESO, NOBROWNOUT, BORV21, PUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, XINST, PBADEN, LPT1OSC, NOMCLR
#use delay(clock=40000000)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
#define LED PIN_D2
#define LEDR PIN_D1
#int_RDA
void RDA_isr(void)
{
}
#int_TBE
void TBE_isr(void)
{
}
int main(void)
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA);
enable_interrupts(INT_TBE);
enable_interrupts(GLOBAL);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
// TODO: USER CODE!!
while (TRUE){
output_toggle(LED);
output_toggle(LEDR);
delay_ms(100);
}
return 0;
}
|
When I comment out enable_interrupts () lines (3 of them) leds start blinking, why ? I have been trying long enough... but I cant figure out why - xtal is 10MHZ
Thanks a lot |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 04, 2007 10:40 pm |
|
|
Your code has at least 5 errors in it.
1. You have XINST enabled. The extended instruction set is not
supported by CCS. You must use NOXINST. If you use XINST, the
program will behave in a crazy way.
2. You have the oscillator fuse set for HS, but you have the frequency
set for 40 MHz. The HS fuse does not enable the PLL. You must use
the H4 fuse. This fuse is listed at the top of the 18F4525.H file.
3. You don't have any code in the #int_rda routine. You must get the
character from the UART by using getc, while inside the #int_rda routine.
4. You don't have any code to send a character or to disable TBE
interrupts inside the #int_tbe routine. Because of this, you will
constantly get a TBE interrupt and keep executing the #int_tbe routine.
5. You have a return statement at the end of main(). It won't be
executed because of the while() loop, but if it was executed, there is
no O/S to return to. You can't "return" to anything from main().
Try the sample #int_rda program shown at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=30380 |
|
|
javi.ar
Joined: 17 Feb 2006 Posts: 59 Location: Argentina
|
Thanks |
Posted: Wed Sep 05, 2007 5:24 am |
|
|
thanks for your time , I´ll give a try tonight and let you know how did it work. |
|
|
javi.ar
Joined: 17 Feb 2006 Posts: 59 Location: Argentina
|
It worked |
Posted: Wed Sep 05, 2007 7:51 pm |
|
|
Yes , It worked , as you stated I correct them all , and voila !!!
Thanks a lot |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|