Please help with uart3 interrupt with LPC1769

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help with uart3 interrupt with LPC1769

492 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xiaozhu1993 on Tue Jun 09 04:12:13 MST 2015
Hi I am using SIM900A and trying to connect it with LPC1769 and make it send message by uart. The system runs with no bugs and no stops but it is not working on the SIM900A which I have tested with tera term, it turns out to be working fine. The attached is my code.

The code is not working so I set a few printf to see where goes wrong. And the result is
1
2
reply: anbcdfsdf
init2
send
finish

So apparently it skips the first printf in the send function which I would like to know why. and the "\n"after the "reply" seems not working.
Could anybody assist me on this to improve the code and make it work?

Thank you very much.
Labels (1)
0 Kudos
1 Reply

459 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Tue Jun 09 14:09:01 MST 2015
Cannot say what the problem is, but do not call printf() in the ISR.
Printf is a big function and it takes a lot of time to execute.

void send(char *txbuf){
   char echo_off[] = "ATE0\r";
   char line1[]="AT\r";
   char linex[] ="AT+IPR=9600\r";

this must be a school project where they tell you that global variables are BAD.
every time you call this function, those strings are created.  Every time the function exits, those strings are destroyed.
Big waste of CPU resources, maybe the compiler optimizer is smart enough to do something about them, but I doubt it.
use the keyword "static" or make them global.

your delay function will not work with a optimized build.  It might not even work in a debug build.  The compiler might just throw away the code since it does nothing.  Why not use SysTick for a delay?

the login in the ISR is hard to follow, I'm bailing out
0 Kudos