Just to be complete, here is what I've done so far.
I'm trying to port the ChibiOS/testhal/STM32F1xx/CAN code to the STM32-P107 board. To do that, I've mostly done 3 things:
1- I've configured the CAN1 TX/RX pins on PD1/PD0 by defining VAL_GPIODCRL to 0x38B888B8 in the P107's board.h and by adding AFIO_MAPR_CAN_REMAP_REMAP3 in the board.c's boardInit() function.
2- I've fixed a bug in the STM32F10X_CL interrupt number definitions (see
http://sourceforge.net/tracker/?func=de ... tid=995489 for the bug report and patch).
3- I've fixed compilation problems due to unknown macros in mcuconf.h. Thus, I've replaced the original HAL driver settings (from the example) by:
Code: Select all
#define STM32_NO_INIT FALSE
#define STM32_HSI_ENABLED TRUE
#define STM32_LSI_ENABLED FALSE
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED FALSE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_PREDIV1
#define STM32_PREDIV1SRC STM32_PREDIV1SRC_PLL2
#define STM32_PREDIV1_VALUE 5
#define STM32_PLLMUL_VALUE 9
#define STM32_PREDIV2_VALUE 5
#define STM32_PLL2MUL_VALUE 8
#define STM32_PLL3MUL_VALUE 10
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_ADCPRE STM32_ADCPRE_DIV4
#define STM32_OTG_CLOCK_REQUIRED TRUE
#define STM32_OTGFSPRE STM32_OTGFSPRE_DIV3
#define STM32_I2S_CLOCK_REQUIRED FALSE
#define STM32_MCOSEL STM32_MCOSEL_PLL3
#define STM32_RTCSEL STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
The thing is I don't really know if these HAL settings are correct (I've copy-pasted from a P107 example). Those are a little bit out of my understanding at the moment... Could it be the source of my problem?
I've tried to debug with an oscilloscope to see what happen. To do that, I saw on the Internet that a resistor is needed between the TX and RX pins. So I've added a resistor and the oscilloscope seems to display a correct signal.
However, when I connect a CAN driver/transceiver (this one:
http://www.skpang.co.uk/catalog/canbus- ... p-754.html), there is nothing on CAN_H and CAN_L...
Furthermore, I noticed that the tx interrupt handler is never called (I tried to increment a volatile int from there) which seems to corroborate the fact that only 3 frames are queued by canTransmit() when I don't use CAN_MCR_NART in the CANConfig, the following ones resulting in a timeout.