2015-02-24 01:50 AM
2015-02-25 04:43 AM
2017-10-02 11:46 PM
iam also faceing same problem can u please help me out of it
2017-10-03 05:11 AM
So what settings are you using and what baud rate do you need?
Stating your own issue and facts might be more helpful in diagnosing your problem?
2017-10-03 09:33 AM
I can run the demo code, which is set to a loop-back mode, but I cannot get normal mode to work.
I think message is not going out of the transmit mailbox. Status is going to pending all the time.
♯ include 'stm32f4xx.h'
♯ include <stdlib.h>CAN_InitTypeDef CAN_InitStructure;
CAN_FilterInitTypeDef CAN_FilterInitStructure; CanTxMsg TxMessage; int mailboxstatus,k,uwCounter,intistatusview; int TransmitMailbox; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; void CAN1_Config(void); void CAN2_Config(void); void NVIC_Config(void); RCC_ClocksTypeDef RCC_Clocks; void Can1WriteData(uint16_t ID); void Can2WriteData(uint16_t ID); void INTTIM_Config(void); int main(void) { //INTTIM_Config(); SystemInit(); RCC_GetClocksFreq(&RCC_Clocks); CAN1_Config(); NVIC_Config(); // CAN_FIFORelease( CAN1,CAN_FIFO0 );while(1)
{ if( CAN_MessagePending( CAN1,CAN_FIFO0)) { } for(int y=0;y<0xffffff;y++); for(int y=0;y<0xffffff;y++); Can1WriteData(0x123); } }void CAN1_Config(void)
{ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_CAN1); GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_CAN1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOD, &GPIO_InitStructure); RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE); CAN_DeInit(CAN1); CAN_StructInit(&CAN_InitStructure); CAN_InitStructure.CAN_TTCM = DISABLE; CAN_InitStructure.CAN_ABOM = DISABLE; CAN_InitStructure.CAN_AWUM = DISABLE; CAN_InitStructure.CAN_NART = DISABLE; CAN_InitStructure.CAN_RFLM = DISABLE; CAN_InitStructure.CAN_TXFP = DISABLE; CAN_InitStructure.CAN_Mode = CAN_Mode_Normal; CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq; CAN_InitStructure.CAN_Prescaler = 2; CAN_Init(CAN1, &CAN_InitStructure); /* CAN filter init */ 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; 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 = CAN_FIFO0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure); TxMessage.StdId = 0x123; TxMessage.ExtId = 0x01; TxMessage.RTR = CAN_RTR_DATA; TxMessage.IDE = CAN_ID_STD; TxMessage.DLC = 8; }void NVIC_Config(void)
{ NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void Can1WriteData(uint16_t ID) { CanTxMsg TxMessage;unsigned int i; TxMessage.StdId = ID;TxMessage.ExtId = 0x00; TxMessage.DLC = 8; TxMessage.Data[0] = 0x02; TxMessage.Data[1] = 0x11; TxMessage.Data[2] = 0x11; TxMessage.Data[3] = 0x11; TxMessage.Data[4] = 0x11; TxMessage.Data[5] = 0x11; TxMessage.Data[6] = 0x11; TxMessage.Data[7] = 0x11; mailboxstatus = CAN_Transmit(CAN1,&TxMessage); for(i=0;i<0x00ffff;i++); while(( CAN_TransmitStatus( CAN1, mailboxstatus ))!=CAN_TxStatus_Ok); k= CAN_TransmitStatus(CAN1, mailboxstatus);}
void INTTIM_Config(void){ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); TIM_TimeBaseStructure.TIM_Period = 41999; TIM_TimeBaseStructure.TIM_Prescaler =1; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); TIM_Cmd(TIM2, ENABLE);}void assert_failed(uint8_t* file, uint32_t line){ while (1) { }}2017-10-03 09:35 AM
iam not getting what is the problem .please help me out of this
2017-10-03 09:37 AM
You would need a second node to communicate with.
2017-11-30 01:37 AM
Hi ..Did your problem get resolved? I am facing the same issue..STM32F4xx connected to busmaster. Transmit status is pending always..And also I see Error Code 2001 ( Bus Error - Bit Error ( Rx) )