• AVR Freaks

Hot!Beware! dsPIC33C with CAN FD requires the data structures to be 4-byte aligned

Author
JPortici
Super Member
  • Total Posts : 711
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: offline
2019/04/12 01:56:17 (permalink)
0

Beware! dsPIC33C with CAN FD requires the data structures to be 4-byte aligned

Hi,
nothing much to report.. Just that the data structure you allocate in memory needs to be 4-byte aligned.
It is not explicitely written anywhere but in the code examples in the reference manual the buffer is 4-byte aligned. I didn't give it much weight until i saw that the structure i allocated in memory held the data shifted by one word (because is was 2-byte aligned).
 
I didn't notice that immediately as the peripheral provides registers that point to the current FIFO entry address.. but this will certainly give memory corruption issues if you allocate just the correct amount of data (as i did)
 
Also explains why the data structures in the code examples are multiple of 4byte in size
#1

1 Reply Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5544
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Beware! dsPIC33C with CAN FD requires the data structures to be 4-byte aligned 2019/04/12 05:45:49 (permalink)
    0
    Looks like Microchip used a CAN FD core which was designed for 32-bit processors.
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5