Part Number: TMS320F280049
Other Parts Discussed in Thread: UNIFLASH, C2000WARE
Hello,
We have recently used DCAN drivers from the 'driverlib'. But we have written our own based on the 'device_support' library ("f28004x_can.h").
The problem that if I flash it using debugger (UniFlash tool or CCS debugger) the project works as expected (all frames match their mailboxes). But when I use customer bootloader that also use the same CAN module, the bootloader works, but when application starts the CAN sends only one remote frame: ID 0x0, DLC 0x0, Data 0x0. I do CAN RAM and CAN module reset, but I have still only one remote frame when I send any data over CAN.
CanaRegs.CAN_CTL.bit.Init = 1u;
CanaRegs.CAN_RAM_INIT.all =
(uint32_t)CAN_ACCESS_TO_RAM_KEY | ((uint32_t)1uL << CAN_RAM_INIT_BIT_POSITION);
while (CanaRegs.CAN_RAM_INIT.bit.RAM_INIT_DONE != 1u) {}
/* Force module to reset state */
EALLOW;
CanaRegs.CAN_CTL.bit.SWR = 1u;
EDIS;
__asm(" RPT #14 || NOP");
CanaRegs.CAN_CTL.bit.CCE = 1u;
After some investigation I have found that the CAN mailboxes are not actually the same as I configured them, so I cannot even receive any data.
There are few questions:
1. why CAN message RAM is not initialized (the same way as it is done in the 'driverlib', except of register access, we use bit access, like CanaRegs.CAN_RAM_INIT.all = (uint32_t)CAN_ACCESS_TO_RAM_KEY | ((uint32_t)1uL << CAN_RAM_INIT_BIT_POSITION); and while (CanaRegs.CAN_RAM_INIT.bit.RAM_INIT_DONE != 1u) {}). And it work are direct flashing.
2. can we actually use bit access for CAN configuration registers: CAN_CTL, CAN_BTR, CAN_TEST, CAN_RAM_INIT, CAN_IP_MUX21 and to CAN interface registers: CAN_IF1CMD (shall be written only via .all when other are configured), CAN_IF1MSK, CAN_IF1ARB, CAN_IF1MCTL?
3. in the 'driverlib' can.c, in the function CAN_setBitTiming, at the end is mentioned that we want to save Init bit if it was set before, but in fact we clear it, so Init bit will be cleared in when bit rate updates. Right, or I skipped something?
//
// If Init was not set before, then clear it.
//
if((savedInit & CAN_CTL_INIT) == CAN_CTL_INIT)
{
savedInit &= ~((uint16_t)CAN_CTL_INIT);
}
HWREGH(base + CAN_O_CTL) = savedInit;
Thank you
Best regards,
Viacheslav Potapov