Problems to handle RS232 interrupts in CCS

Status
Not open for further replies.

Plateau

Junior Member level 3
Joined
Jan 4, 2012
Messages
30
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,553
lks, is everybody ok?

I'm making a Track System using a GSM and GPS module, both controlled by a PIC18F4680. At the moment, I'm facing a big problem to handle the data that come through USART using the interrupt approach. I don't know why, but after enabling the RS232 receive data available (#INT_RDA) interrupt, the LCD stops working (lcd_putc or printf through LCD don't work) and the microcontroller seems to stuck in some part.

My code is below. If someone can help me with these problems, feel free for making changes in my code.

Thanks in advance,

Pedro Rosa.

P.S: The compiler used was CCS 4.130

main.c


defines.h


function.c
 
Last edited:

Hiho, folks.

I've realized that if I don't call the function (inicializaPIC() at void main() and uncomment this line (//putc(caracterRecebido, PK2) at void RDA_ISR(void) (#INT_RDA function) I receive all the answer for AT commands that I've made.

Could anybody help me? I'm freaking out Haha
 

Your code inside the min() function has many delays and that is causing the problem. You have to use Serial Interrupt for RS232 communication.
 
Hello, jayanth, are you fine?

Thank you so much for having answered me! Is the min() function the main() function? How can I get rid of these delays? Could you show me?

Is the Serial Interrupt for RS232 communication one of CCS' example programs (EX_SISR.C or EX_STISR.C)?

One more time, thanks in advance.

Regards,

Pedro Rosa!

P.S: I don't know why, but if I get rid of the interrupt routine and use a loop with KBHIT, the code works. I think the problem is really the many delays across my code... but I don't know how to solve this.
 
Last edited:

Sorry, that was a typo. it was indeed main() function. I haven't used CCS C. So you check the sample programs in CCS C. It surely contains UART examples which use Serial Interrupts. Post me the sample files. i will look into it. You can have delays in main() and use Serial Interrupt for receiving data. When serial Interrupt occurs it is serviced first and then other code will be executed.
 

Thanks, jayanth.

The examples are:


and

 

In your void inicializaPIC() function there is an else statement which contains a infinite for( ; ; ) loop. So, inicializaPIC() is called from main() then if the execution enters the else block and for( ; ; ) loop it will never come out of it even there is a serial interrupt. So your code in the main()'s while(1) loop will never be executed.
 

I've suspected that this part and thus I've decided call only isGSMOk() from main function for checking what will happen. So, something strange happens in this part:


In the moment, I'm getting rid of the interrupt approach and coming back to the KBHIT way until I see what I've done wrong. Now, my code is this below. It's not so brilliant but it works.


One more time, thanks for having helped me.

Best wishes.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…