CAN data register problem?

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

CAN data register problem?

865 Views
pg31321
Contributor III

My program like this:

breakpoint.jpg

"Check_CAN_MB_Status(0, 0, buffer_status);" is a subprogram what detect if there is new data in the CAN register.

When there is new data,"(buffer_status[0] == NEWDATA) "is true.

"Read_CAN_MB_Data(0, 0, Receive_Data);" is read CAN register date and save in "Receive_Data".

Then,I add breakpoint at Switch case 0x0C "RPM_L = RPM & 0x00ff ;"

When I transfer data(0x01 0x41 0x0C 0xff 0xff) with CAN.

The program stops in the right place. but,The variable array"Receive_Data[3]" display 0x00.

What happened with it?

If the variable array"Receive_Data[3]" really is 0x00. Why program stops in there?

Program execution result :"RPM = 0"

Labels (1)
0 Kudos
Reply
1 Reply

744 Views
stanish
NXP Employee
NXP Employee

Hi,

First I'd suggest you to switch off compiler optimization if there is any.

Seems there are valid data in the buffer when switch statement is executed since it jumped into a valid switch case.

What is RPM? a variable or a macro?

Is there any interrupt routine transfer running on the background may overwrite Receive_Data variable?

As a general debug suggestion I'd place a write watchpoint at address Receive_Data[3]. The execution stops at the moment any code is writing to this address.

This may help you to figure out what has changed the buffer.

pastedImage_2.png

pastedImage_3.png

Hope it helps.

Stan

0 Kudos
Reply