2024-06-17 07:54 AM
Hi all,
I'm using MCP2515 for a CAN application in the NUCLEO STM32WL board. I've managed to get it to work in pulling mode, however, I want to use interrupt mode.
For what I looked, I just have to enable the MCP interrupt pin in EXTI mode in cubeMX, but the MCP interrupt pin that I set (PA0) is already set as the BUT1 pin (on board button). I didn't change the configurations, only set in the callback to activate if occurs the rising edge of BUT1_Pin (tried with falling edge too).
It didn't work, but I don't know if I have to configure something more, or the fact that the pin is shared with the button changes something and it could be the problem.
Any insights will be helpfull.
2024-06-17 08:32 AM
And how is the Button wired? Pull-up to VCC, button pressed to GND ?
Not sure the MCP2515 uses an open-collector output, or can be configured from a driver, level or pulse sense. Sure the Data Sheet would elucidate.
Use EXTI0
Use a scope and confirm behaviour and expectations
2024-06-17 09:34 AM - edited 2024-06-17 09:34 AM
Here's the schematic of BUT1 pin. I'm not sure if the PA0 bypasses this connection, or if would only work if the button is pressed
2024-06-17 09:46 AM
Ok, so NUCLEO-WL55JC(1) board
You could remove the solder-bridge (SB16) or link, or move to PC13 (SB15) if nothing else conflicts, and use the EXTI15_9
That would free PA0 for your own, personal use, on the MORPHO connection/headers
2024-06-17 09:58 AM
Ok, so if I just remove the SB16 solder, the PA0 pin would be available to use on the MORPHO connectors, or simply just use the PC13 pin, right?
2024-06-25 01:29 PM
Hey, just updating.
I changed, the pin I was using for the interrupt. It is connected directly to the interrupt MCP2515 IC pin. I pu the osciloscope on the pin, and couldn't see nothing, only a voltage offset.
What could it be? I need to do something else?
2024-06-25 08:30 PM
Have you programmed the mcp registers to generate interrupt. If you post the code we can analyse
2024-06-26 12:04 PM
I don't think so, at least not in the main code. The callback code follows:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == CAN_INT_Pin) //MCP2515 Interrupt Pin
{
//CAN receiving messages (Packages MUST start from the smaller data)
if(CANSPI_Receive(&rxMessage))
{
switch(rxMessage.frame.id)
{
//------------ BMS packages ------------ (2 bytes variables must be inverted)
case 0x672:
bms_fail = (rxMessage.frame.data4);
break;
case 0x673:
accumulator_voltage = ((rxMessage.frame.data0 << 8) | rxMessage.frame.data1);
min_cell_voltage = (rxMessage.frame.data2);
max_cell_voltage = (rxMessage.frame.data4);
break;
...
...
...
}
}
To make it work I'm using this library: https://github.com/eziya/STM32_SPI_MCP2515.git
(MCP2515 and CANSPI files)
I don't know if this does program the registers to generate the interrupt or has a function of some kind to do it.
2024-06-26 06:29 PM
Ad per datasheet the int pin can be configured for different purposes. Are you using any breakout, then check the jumpers. I guess it needs pullups
2024-06-26 07:34 PM
Also don't know, here's the schematic on the board (consider PA0 as PB14 (CAN_INT_Pin))