SMT32f407VG(bare-metal) and ARDUINO CANbus communication

-1

STM32 iso1050(CANbus ic) connection(eagle)

Arduino MCP2515(CANbus shield) connections

iso1050 and mcp2515 are connected canH to canH and canL to canL

 #include <stm32f4xx.h>
    #include "can.h"
    #include "can bus.h"

    void CAN1_TX_IRQHandler (void) {

     if (CAN1->TSR & CAN_TSR_RQCP0) {          /* request completed mbx 0      */
     CAN1->TSR |= CAN_TSR_RQCP0;             /* reset request complete mbx 0   */
     CAN1->IER &= ~CAN_IER_TMEIE;            /* disable  TME interrupt         */

      CAN_TxRdy[0] = 1; 
    }
   }

   unsigned int arduinoID = 0x0F;
   int i;

int main(void){

    unsigned int i;
  for (i=0;i<0x00100000;i++);     // OSC start delay
  RCC->CFGR |= 0x00009400;        // AHB ve APB speeds are max
  RCC->CR |= 0x00010000;          // HSE Xtal osc start run      
  while (!(RCC->CR & 0x00020000));// Xtal osc stabilize check
  RCC->PLLCFGR = 0x07402A04;      // PLL parameters M=4, N=168, P=2 ve Q=7 yapalim   168 Mhz 
  RCC->CR |= 0x01000000;          // PLL start run
  while(!(RCC->CR & 0x02000000)); // Pll staabilize check
  FLASH->ACR = 0x00000605;        // Flash ROM icin 5 Wait state and ART activite
  RCC->CFGR |= 0x00000002;        // System Clk fed via PLL 
  while ((RCC->CFGR & 0x0000000F) != 0x0000000A); // wait till system clock fed via PLLL
  RCC->AHB1ENR |= 0x0000001F;     // GPIO A,B,C,D,E clock's activated

    CanBusInit();
    /*      ID(arduino code accept all IDes
                Lenght
                DATA

                Other CAN bus information are set "CAN bus.c"
    */
    CAN_TxMsg[1].id     = arduinoID;
    CAN_TxMsg[1].len  = 8;

    CAN_TxMsg[1].data[0] = 'C';
    CAN_TxMsg[1].data[1] = 'A';
    CAN_TxMsg[1].data[2] = 'N';
    CAN_TxMsg[1].data[3] = ' ';
    CAN_TxMsg[1].data[4] = 'B';
    CAN_TxMsg[1].data[5] = 'U';
    CAN_TxMsg[1].data[6] = 'S';

    while(1){
        for(i = 0; i<100000 ;i++);                              //small delay
        CAN_wrMsg(1, &CAN_TxMsg[1]);                            //sending the data
    }   
}

libary links from code that i use:

can.c -->https://hastebin.com/abejabuzen.m

can.h -->https://hastebin.com/lorequhuwa.cpp

can bus.c -->https://hastebin.com/wipudeziji.md

can bus.h -->https://hastebin.com/uteraganar.md

ARDUINO reciever CODE: https://hastebin.com/ifanazoduv.m

Problem description: mainly arduino doesnt recieve any information. Arduino tested by CANbus adapter and recieve every data from any ID. STM32 starts initilaize without problem put the data in can mailBox but no data recieved from arduino. When i checked the pins(CANH, CANL) with oscillator no signal is on the monitor.

arduino
stm32
keil
bare-metal
can-bus

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0