My program like this:
"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 == 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" display 0x00.
What happened with it?
If the variable array"Receive_Data" really is 0x00. Why program stops in there?
Program execution result :"RPM = 0"
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. 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.
Hope it helps.