Hi! I've got a problem with configuring CAN on STM32. I've managed to write a program based on ST examples to send data by loopback mode. The only problem is, there is no signal going out from the chip. Do I have to define somehow the pinouts for CAN other than just:
/* Configure CAN pin: RX*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Configure CAN pin: TX*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
I want to send data on pins no. 96 and 95 (PB9 & PB8). They can be programmed to serve as CAN TX/RX. In the examples, there was only a program written for pins PA12 and PA11. I've got USB port attached to those pins, and a CAN transciver attached to pins 95 and 96.
EDIT: And another thing. I've managed to connect the usb/can pins so that I use different pinouts than I intended to. Now the voltage outputs are correct (2,5V). The problem is, I based on an example by ST for can, and it is kind of strange. The example allows to read data by loopback function using polling and interrupts. I've used the part with interrupts. After startup and basic configurations (clk, interrupts etc.) I wanted to transmit TxMessage - address and so on. The problem is, when the program runs the function responsible for this, the whole board goes to the infinite loop thanks to
u8 i=0;
while((ret==0xFF)&&(i<0XFFF))
i++;
if (i==0xFFF)
ret=0;
Is it a mistake made by ST or is it a delay loop? This 'while(...)' loop makes the chip ignore interrupts from USART and CAN RX, bu only when using Normal mode of CAN. When I use LoopBack mode, everything works fine, maybe except the lack of any transsmition on CAN_H, CAN_L pinouts of my board. In the loop back mode, there still should be some transsmition from the chip, but the voltages sugest the recessive mode on the CAN interface. Any thoughts?
Last edited by payatz (2010-04-14 13:43:20)