/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / OBD2-CAN using STM32 !

Username:     
Password:     
             

Forum

# 1   2011-12-04 13:50:32 OBD2-CAN using STM32 !

himas88
New member
Registered: 2011-12-03
Posts: 1

OBD2-CAN using STM32 !

Hello everybody !

Sorry my English. I have a problem in my project. I don't connect my Tool with ECU using OBD 2.

I check my CAN network . It's OK.

To connect ECU, First I send a mesage bellow :

Code:

#define PID_REQUEST         0x7DF 
#define PID_REPLY   0x7E8    

// initialise message to send    
CAN_TxMsg.id = PID_REQUEST;    // 0x7DF  
CAN_TxMsg.len = 8; 
CAN_TxMsg.format = STANDARD_FORMAT; 
CAN_TxMsg.type = DATA_FRAME; 
while (1) { 
test=0 ;                          
if (CAN_TxRdy) { 
CAN_TxRdy = 0;          

CAN_TxMsg.data[0] = 0x02;                    
 CAN_TxMsg.data[1] = 0x01; 
CAN_TxMsg.data[2] = pid ; // PID's need to get 
CAN_TxMsg.data[3] = 0x00; 
CAN_TxMsg.data[4] = 0x00; 
CAN_TxMsg.data[5] = 0x00; 
CAN_TxMsg.data[6] = 0x00; 
CAN_TxMsg.data[7] = 0x00;                 
CAN_wrMsg (&CAN_TxMsg); 
CAN_wrMsg (&CAN_TxMsg); // transmit message    
}    
delay (100000);    // waiting CAN transmit about 500ms.

After , I wait Receive Interrupt... and ECU don't receive data.

This my program :

Code:

if (CAN_RxRdy) {
            CAN_RxRdy = 0;            
            test = CAN_RxMsg.data[0];
        }
    
        if (test==0x02)
        {
            /* Turn on led connected to GPIO_LED pin9 (LD4) */
        
            GPIO_WriteBit(GPIOC, GPIO_Pin_11, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_11)));
        }
                else
        {
            GPIO_WriteBit(GPIOC, GPIO_Pin_4, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_4)));    
        }

    } // end while

In this code, I check Receiver Interupt, If it occurt, LED in PC11 or PC4 isTOOGLE. If not,both LED in PC11 and PC4 is TOOGLE.

Thank everyone !

Last edited by himas88 (2011-12-04 13:54:37)

Offline

 

# 2   2012-03-02 11:57:12 OBD2-CAN using STM32 !

repzak
Member
Registered: 2008-03-05
Posts: 170

Re: OBD2-CAN using STM32 !

Hi,

Any progress on this?, i maybe want to run same project?

Offline

 

# 3   2012-03-13 15:44:16 OBD2-CAN using STM32 !

Matthias
Member
From: Germany
Registered: 2010-01-30
Posts: 20

Re: OBD2-CAN using STM32 !

what you prefer German or English

What kind of primer 1 2?
Primer 1 : http://www.stm32circle.com/projects/project.php?id=116
Primer 2 : http://www.stm32circle.com/projects/project.php?id=113

Possible causes:
Incorrect baud rate
    CAN_InitStructure.CAN_Prescaler = 4;
    CAN_InitStructure.CAN_BS1 = 8;
    CAN_InitStructure.CAN_BS2 = 7;

Incorrect filter set:
    CAN_FilterInitStructure.CAN_FilterNumber = 0;
    CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
    CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
    CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
    CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
    CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
    CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
    CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
    CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;

not interrupt enabled
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_PriorityGroupConfig (NVIC_PriorityGroup_0);
    NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init (& NVIC_InitStructure);

Last edited by Matthias (2012-03-13 15:51:24)


Wer Rechtschreibfehler findet, darf sie behalten
english by translate.google.com
Whoever finds typos may keep them

Offline

 

# 4   2012-03-20 19:12:31 OBD2-CAN using STM32 !

jorgea
New member
Registered: 2012-03-20
Posts: 2

Re: OBD2-CAN using STM32 !

Have you seen any success in this yet?

Offline

 

Board footer