Datasheet
Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
25
CAN Waveform:
This is an oscilloscope photo of a CAN frame from our example.
The first negative edge is the SOF (start of frame). The last negative pulse is the ACK bit. It moves about due to stuffed bits.
The first five positive pulses stay the same. They are the ID field. The others change as the data field and CRC change.
The most narrow pulse is 2 µsec wide and ½ µsec =
500 kHz. This is the CAN frequency in our example.
The base is 0.665 volts and the top is at 3.0 volts.
The P-P voltage is ~ 2.375 volts positive going.
Remember this is not a valid CAN physical layer.
You will not be able to connect this to a real CAN
network. If you did, I expect there will be many bus
errors created. But as you can see, it is very useful
for small experimental networks.
Data Tracing: a practical debugging example… (for reference only)
1. This is an example ran on a particular Cortex-M3 board. Val_Tx is displayed in the Logic Analyzer (LA).
2. The variable CAN_RxMsg[0].data[0] is also displayed in the Logic Analyzer as shown here:
3. With the program running, the potentiometer was
varied which varied val_Tx. The screen displayed
the value of val_Tx in real-time as shown here in the
Logic Analyzer:
If you think this graph doesn’t reflect what you think a pot
rotated should look like you are correct ! The pot on this
particular board is defective (it has many bad spots) and I
have saved it for demonstrations like this. This problem was
not apparent by turning the pot and watching the LCD.
However, watching the data writes in the Trace Records
reveals what is really happening. See in the Data column as I
rotate from 77 to C1 there is a short drop down to the 30s – this in one of the bad spots and this is why the graph has the
sharp jumps. This problem was confirmed with a CAN analyzer attached to the bus and an oscilloscope on the pot.
Usefulness of Serial Wire Viewer (SWV):
This is one example of the usefulness of Serial Wire Viewer. It could be otherwise very difficult to find this problem with
without Serial Wire Viewer. There are many instances SWV is useful and here are a few examples:
Another good use is finding interrupts that fire too often using up CPU time and slowing your program down. I saw this once
where the developer thought he had disabled the DMA. The DMA interrupts in the Exceptions window told a different story.
Once he actually disabled the DMA and made its interrupts stop, his program ran much faster.
Viewing variables that do not exist in the real world and only in formulae and variables (and therefore cannot be measured
with instruments) is another good example.
The data displayed by SWV (except for the Debug (printf) Viewer) is non-intrusive and no CPU cycles are stolen.
ETM Trace:
ETM trace, available with nearly all ST STM32 processors, captures and displays all the instructions executed. It works in
conjunction with SWV. ETM is extremely useful in program flow problems or when the processor “goes-into-the-weeds”.
ETM also provides Code Coverage, Performance Analysis and Instruction Execution capabilities. A Keil ULINKpro is
needed to collect ETM trace frames from the STM32 Trace Port. See www.keil.com/appnotes/docs/apnt_230.asp