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);
}
}