Problem with Serial Communication

Discussion to talk about software related topics only.
Post Reply
nicobari
Posts: 110
Joined: Mon Jan 30, 2012 12:15 pm

Problem with Serial Communication

Post by nicobari »

Hi, I am trying to receive data from my GPS and my data receiving part of code is as follows

Code: Select all

while(!charavail(UART0));
GPS[0]=sgetchar(UART0);
if(GPS[0]==0xAA){
Pins[21]=1;
while(!charavail(UART0));
GPS[1]=sgetchar(UART0);

while(!charavail(UART0));
GPS[2]=sgetchar(UART0);

if((GPS[1]==0x44)&& (GPS[2]==0x12)){
i=3;
while(charavail(UART0)&& i<100 ){
GPS[i]=sgetchar(UART0);
i++;
}
}
}
But when I uploaded and ran the code I am getting the following error

Waiting 5sec(s) to start 'A' to abort

Netburner MOD5213 Monitor V1.2 Dec 22 2009 13:14:17
Valid commands are
FLA (Flash load)
Setup
Boot
Version
Reset

NB>Download S record, X to abort
Go:BDB
Waiting 5sec(s) to start 'A' to abort
GPS_IMU_Data_Logger17
-------------------Trap information-----------------------------
Exception Frame/A7 =20002E04
Trap Vector =Access Error (2)
Format =03
Status register SR =2008
Fault Status =0C
Faulted PC =FFC04506

-------------------Register information-------------------------
A0=00000000 A1=2000040C A2=20002E3F A3=FFC04CDC
A4=FFC04C2C A5=FFC04EC4 A6=20002ED4 A7=20002E04
D0=00008033 D1=00000009 D2=00000044 D3=00000012
D4=00000044 D5=20002ED3 D6=20002EA0 D7=FFC09E14
SR=2008 PC=FFC04506
-------------------RTOS information-----------------------------
The OSTCBCur current task control block = 20001D38
This looks like a valid TCB
The current running task is: Main,#32
-------------------Task information-----------------------------
Task | State |Wait| Call Stack
Idle,#3F|Ready | |FFC06A24,0
Main,#32|Running | |FFC04506,FFC09908,0

-------------------End of Trap Diagnostics----------------------
Waiting 5sec(s) to start 'A' to abort
GPS_IMU_Data_Logger17
-------------------Trap information-----------------------------
Exception Frame/A7 =20002E04
Trap Vector =Access Error (2)
Format =03
Status register SR =2008
Fault Status =0C
Faulted PC =FFC04506

-------------------Register information-------------------------
A0=00000000 A1=2000040C A2=20002E3F A3=FFC04CDC
A4=FFC04C2C A5=FFC04EC4 A6=20002ED4 A7=20002E04
D0=00008034 D1=00000009 D2=00000044 D3=00000012
D4=00000044 D5=20002ED3 D6=20002EA0 D7=FFC09E14
SR=2008 PC=FFC04506
-------------------RTOS information-----------------------------
The OSTCBCur current task control block = 20001D38
This looks like a valid TCB
The current running task is: Main,#32
-------------------Task information-----------------------------
Task | State |Wait| Call Stack
Idle,#3F|Ready | |FFC06A24,0
Main,#32|Running | |FFC04506,FFC09908,0

-------------------End of Trap Diagnostics----------------------
Waiting 5sec(s) to start 'A' to abort
GPS_IMU_Data_Logger17
-------------------Trap information-----------------------------
Exception Frame/A7 =20002E04
Trap Vector =Access Error (2)
Format =03
Status register SR =2008
Fault Status =0C
Faulted PC =FFC04506

-------------------Register information-------------------------
A0=00000000 A1=2000040C A2=20002E3F A3=FFC04CDC
A4=FFC04C2C A5=FFC04EC4 A6=20002ED4 A7=20002E04
D0=00008035 D1=00000009 D2=00000044 D3=00000012
D4=00000044 D5=20002ED3 D6=20002EA0 D7=FFC09E14
SR=2008 PC=FFC04506
-------------------RTOS information-----------------------------
The OSTCBCur current task control block = 20001D38
This looks like a valid TCB
The current running task is: Main,#32
-------------------Task information-----------------------------
Task | State |Wait| Call Stack
Idle,#3F|Ready | |FFC06A24,0
Main,#32|Running | |FFC04506,FFC09908,0

-------------------End of Trap Diagnostics----------------------
Waiting 5sec(s) to start 'A' to abort
what am I doing incorrect? I would appreciate any help. Thanks in advance.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Problem with Serial Communication

Post by tod »

You haven't stated what you have tried so forgive me if I state some things you've already done.

First, as a wild guess from the small snippet you show, I would guess you didn't allocate enough memory for the GPS array and you're trashing memory, but I have no evidence as you don't show enough code. So on to more practical advice:

Your NNDK contains a program called WinAddr2Line you can specify in this little app both the location of your project ELF file and you can paste it the addresses you want translated. In your case the most likely items to return usuable information are

Code: Select all

Main,#32|Running | |FFC04506,FFC09908,0
Put both of those in separated by spaces and it may point you to the offending line. Oftentimes, if you've corrupted memory it will point you to something that failed because memory was corrupted. That is it might point you at something well past the offending code.

The second easiest thing you can do is compare the current version to the last version that worked using your source code control system. Take a good hard look at any printf's you might have added.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Problem with Serial Communication

Post by tod »

The other thing you did wrong (and you aren't alone) was you didn't first write this code for a library and then unit test it with a unit testing framework written expressly for the NetBurner (tested on the MOD5272).

I'm taking this opportunity to extol one of the virtues of unit testing. While your code would most likely still cause the NetBurner to trap in a unit test, it would NOT be caught in an endless trap cycle. In other words your unit test runner application would reload safely and as long as you don't re-run the test you won't trap. This allows you to fix your code and reflash your NB over Ethernet.

As it stands you have to reflash your NB over the serial port after cold-booting and hitting SHIFT-A to break into the monitor. If you are trying to trace down the problem using cout or (I hate to type it) printf, you might have to go through the trap/cycle serial flash process multiple times.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Problem with Serial Communication

Post by Ridgeglider »

Tod: It looks like the NB nicobari is working with is the 5213 which of course has no ethernet and a pretty small memory footprint that may not allow either a large array for GPS or the unit test framework useful as it is...

I'd try to download a know good app, say the factory demo, or perhaps one of the examples in C:\nburn\examples\MOD5213 using the FLA approach from the monitor. Taks a look at the serial port API docs in section 6 of the C:\nburn\docs\5213ProgrammersGuide\Mod5213ProgrammersGuide.pdf. I'd recommend using the interrupt-based serial drivers.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Problem with Serial Communication

Post by tod »

:oops: Thanks ridge, sorry nico, I should have read more carefully. The small footprint not only rules out the unit testing framework it probably rules out the use of iostream as well. In addition to memory overruns, and mis-matched printfs, you probably need to be careful about your stack. I'll bow out now as I have only very limited experience with the smaller memory modules and none at all with the 5213. A NetBurner without Ethernet hmmm, I always thought the Net in NetBurner was...
Post Reply