cancel
Showing results for 
Search instead for 
Did you mean: 

MCP2515 in Interrupt mode using STM32WL

FPicc.1
Senior

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.

10 REPLIES 10

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

FPicc1_0-1718642006634.png

 

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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?

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?

Have you programmed the mcp registers to generate interrupt.  If you post the code we can analyse

If you feel a post has answered your question, please click "Accept as Solution".

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.

Techn
Senior III

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 

If you feel a post has answered your question, please click "Accept as Solution".

Also don't know, here's the schematic on the board (consider PA0 as PB14 (CAN_INT_Pin))

FPicc1_0-1719455665702.png