Hi,
I'm currently working on a library for use on LPC15xx microcontrollers, part of the library is a CAN module and I'm seeing some really strange behaviour.
To better explain what I have, I have two stages to the library. The CAN module of the higher level library is built on a lower level CAN library I wrote to the Canpie spec, but the higher level library has a lot of other stuff like generic interfaces to GPIO, timers, UART etc.
Now when I test just the low level Canpie library functions, everything works fine. But when I use my higher level library the data segments in my CAN packets are not what they should be. The higher level library calls the exact same functions as my Canpie test does as well. Right now I'm trying to pass a CAN packet full of 0's in the data segment (DLC of 8) but my output has occasional bits changed or simply doesn't give out a valid CAN packet, though the ID is always fine. I really have no idea what could be causing this and would appreciate any help. I'm worried it could be some sort of memory or stack issue, but the DA registers on the C_CAN0 peripheral never go non-zero as far as I can see in debugging so I still have no idea what it could be.
I've attached a sample of the output I get from my Salae logic analyser, hooked up to the TX pin on the LPC1549 dev board, reminder that the data should be all zeroes. In case it helps anyone.
Time [s] Analyzer Name Decoded Protocol Result 2.255614 CAN Extended CAN Identifier: 405898241 2.255686 CAN Control Field: 8 bytes 2.255694 CAN Data Field Byte: 0 2.255714 CAN Data Field Byte: 0 2.255732 CAN Data Field Byte: 0 2.255752 CAN Data Field Byte: 0 2.255772 CAN Data Field Byte: 8 2.255788 CAN Data Field Byte: 0 2.255808 CAN Data Field Byte: 0 2.255826 CAN Data Field Byte: 0 2.255846 CAN CRC value: 20654 2.255878 CAN NAK 3.149655 CAN Extended CAN Identifier: 405898241 3.149727 CAN Control Field: 8 bytes 3.149735 CAN Data Field Byte: 0 3.149755 CAN Data Field Byte: 0 3.149773 CAN Data Field Byte: 0 3.149793 CAN Data Field Byte: 0 3.149813 CAN Data Field Byte: 8 3.149829 CAN Data Field Byte: 0 3.149849 CAN Data Field Byte: 0 3.149867 CAN Data Field Byte: 0 3.149887 CAN CRC value: 20654 3.149919 CAN NAK 4.220714 CAN Extended CAN Identifier: 405898241 4.220786 CAN Control Field: 8 bytes 4.220794 CAN Data Field Byte: 0 4.220814 CAN Data Field Byte: 0 4.220832 CAN Data Field Byte: 0 4.220852 CAN Data Field Byte: 0 4.220872 CAN Data Field Byte: 8 4.220888 CAN Data Field Byte: 0 4.220908 CAN Data Field Byte: 0 4.220926 CAN Data Field Byte: 0 4.220946 CAN CRC value: 20654 4.220978 CAN NAK 5.03876 CAN Extended CAN Identifier: 405898241 5.038832 CAN Control Field: 8 bytes 5.03884 CAN Data Field Byte: 0 5.03886 CAN Data Field Byte: 0 5.038878 CAN Data Field Byte: 0 5.038898 CAN Data Field Byte: 1 5.038916 CAN Data Field Byte: 0 5.038934 CAN Data Field Byte: 0 5.038954 CAN Data Field Byte: 0 5.038972 CAN Data Field Byte: 0 5.038992 CAN CRC value: 20654 5.039024 CAN NAK 5.869806 CAN Extended CAN Identifier: 405898241 5.869878 CAN Control Field: 8 bytes 5.869886 CAN Data Field Byte: 0 5.869906 CAN Data Field Byte: 0 5.869924 CAN Data Field Byte: 0 5.869944 CAN Data Field Byte: 0 5.869964 CAN Data Field Byte: 8 5.86998 CAN Data Field Byte: 0 5.87 CAN Data Field Byte: 0 5.870018 CAN Data Field Byte: 0 5.870038 CAN CRC value: 20654 5.87007 CAN NAK 6.634848 CAN Extended CAN Identifier: 405898241 6.63492 CAN Control Field: 8 bytes 6.634928 CAN Data Field Byte: 0 6.634948 CAN Data Field Byte: 0 6.634966 CAN Data Field Byte: 0 6.634986 CAN Data Field Byte: 0 6.635006 CAN Data Field Byte: 8 6.635022 CAN Data Field Byte: 0 6.635042 CAN Data Field Byte: 0 6.63506 CAN Data Field Byte: 0 6.63508 CAN CRC value: 20654 6.635112 CAN NAK