Debug bus CAN on a STM32F767 Nucleo 144
Posted: Fri Apr 19, 2019 8:53 pm
I'd would appreciate any help on this problem, as I've run out of ideas to solve it: I have developed a plugin board for a STM32F767 Nucleo-144; everything worked as designed, except for the CAN bus. I use PD0 (CAN1RX) and PD1 (CAN1TX) pins, and a MCP2551 for the interface.
There are no signals on the bus, but it works when in loopback (I receive frames). According to the reference manual, in loopback mode the TX signals should be shown at the TX pin, however there isn't any signal even with the board unplugged.
It seems a problem with the pin configuration, but I can't see it.
The basic code to test the loopback is:
There are no signals on the bus, but it works when in loopback (I receive frames). According to the reference manual, in loopback mode the TX signals should be shown at the TX pin, however there isn't any signal even with the board unplugged.
It seems a problem with the pin configuration, but I can't see it.
The basic code to test the loopback is:
Code: Select all
static const CANConfig cancfg = {
CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
CAN_BTR_LBKM | CAN_BTR_SJW(0) | CAN_BTR_TS2(1) |
CAN_BTR_TS1(8) | CAN_BTR_BRP(6)
};
void testCAN(void)
{
CANTxFrame txmsg;
float valor = 3.45;
palClearPad(GPIOD, GPIOD_CAN1_TX);
palSetPad(GPIOD, GPIOD_CAN1_RX);
palSetPadMode(GPIOD, GPIOD_CAN1_RX, PAL_STM32_ALTERNATE(9));
palSetPadMode(GPIOD, GPIOD_CAN1_TX, PAL_STM32_ALTERNATE(9));
palSetPadMode(GPIOD, GPIOD_CAN1_EN, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(GPIOD, GPIOD_CAN1_EN);
canStart(&CAND1, &cancfg);
canStart(&CAND2, &cancfg);
txmsg.IDE = CAN_IDE_STD;
txmsg.RTR = CAN_RTR_DATA;
txmsg.DLC = 4;
txmsg.EID = 7;
for (;;)
{
memcpy(txmsg.data32,(void *) &valor, 4);
canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg, TIME_MS2I(100));
osalThreadSleepMilliseconds(100);
}
}