你的浏览器版本过低,可能导致网站不能正常访问!为了你能正常使用网站功能,请使用这些浏览器。
举报
查看全部评分
zhulikai 发表于 2016-10-10 15:39 程序好大,20160929_Test_CAN\20160929_Test_CAN\Projects\STM32F334R8-Nucleo\Templates\MDK-ARM
laiyingjie 发表于 2016-10-10 19:15 关于STM32CubeMX软件配置方面,楼主可以参考这个链接内容:http://www.waveshare.net/study/article-651-1. ...
安 发表于 2016-10-10 15:48 can基本一样,如果收不到,说明配置的问题。也可以用STM32CubeMX生成测试工程。 ...
zhangdaijin 发表于 2016-10-11 05:43
zhulikai 发表于 2016-10-11 14:39 牙挺白牙挺白
STM32隐藏
5.18活动板子会不会是STM32L4呢
STM32 CUBE软件中找不到STM32L4系列单片机
Your UAT Feedback is needed within today.
应用
AAA
标签选择失败
tiwen
BBBB
aaa
int main(void)
{
static GPIO_InitTypeDef GPIO_InitStruct;
static CAN_HandleTypeDef CAN_HandleStruct;
static CAN_FilterConfTypeDef CAN_FilterConfStruct;
static CanTxMsgTypeDef CanTxMsgStruct;
static CanRxMsgTypeDef CanRxMsgStruct;
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned int u32;
typedef unsigned __int64 u64;
u8 Txbuf[8];
u8 Rxbuf[8];
u8 i;
u8 cnt = 0;
HAL_Init();
SystemClock_Config();
__HAL_RCC_CAN1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
CAN_HandleStruct.Init.ABOM = DISABLE;
CAN_HandleStruct.Init.AWUM = DISABLE;
CAN_HandleStruct.Init.BS1 = CAN_BS1_7TQ;
CAN_HandleStruct.Init.BS2 = CAN_BS2_6TQ;
CAN_HandleStruct.Init.Mode = CAN_MODE_LOOPBACK;
CAN_HandleStruct.Init.NART = ENABLE;
CAN_HandleStruct.Init.Prescaler = 6;
CAN_HandleStruct.Init.RFLM = DISABLE;
CAN_HandleStruct.Init.SJW = DISABLE;
CAN_HandleStruct.Init.TTCM = DISABLE;
CAN_HandleStruct.Init.TXFP = DISABLE;
CAN_HandleStruct.Instance = CAN;
CAN_HandleStruct.Lock = HAL_UNLOCKED;
CAN_HandleStruct.pRxMsg = &CanRxMsgStruct;
CAN_HandleStruct.pTxMsg = &CanTxMsgStruct;
HAL_CAN_Init(&CAN_HandleStruct);
CAN_FilterConfStruct.BankNumber = 0;
CAN_FilterConfStruct.FilterActivation = ENABLE;
CAN_FilterConfStruct.FilterFIFOAssignment = CAN_FILTER_FIFO0;
CAN_FilterConfStruct.FilterIdHigh = 0x0000;
CAN_FilterConfStruct.FilterIdLow = 0x0000;
CAN_FilterConfStruct.FilterMaskIdHigh = 0x0000;
CAN_FilterConfStruct.FilterMaskIdLow = 0x0000;
CAN_FilterConfStruct.FilterMode = CAN_FILTERMODE_IDMASK;
CAN_FilterConfStruct.FilterNumber = 0;
CAN_FilterConfStruct.FilterScale = CAN_FILTERSCALE_32BIT;
HAL_CAN_ConfigFilter(&CAN_HandleStruct, &CAN_FilterConfStruct);
while(1)
{
for(i=0;i<=8;i++)
{
Txbuf[i]=cnt+i;
}
CanTxMsgStruct.DLC = 8;
CanTxMsgStruct.ExtId = 0x12;
CanTxMsgStruct.IDE = 0;
CanTxMsgStruct.RTR = 0;
CanTxMsgStruct.StdId = 0x12;
for(i=0;i<8;i++)
CanTxMsgStruct.Data[i]=Txbuf[i];
HAL_CAN_Transmit(&CAN_HandleStruct,0);
HAL_CAN_Receive(&CAN_HandleStruct,CAN_FIFO0, 1000);
for(i=0;i<CanRxMsgStruct.DLC; i++)
Rxbuf[i] = CanRxMsgStruct.Data[i];
if(CanRxMsgStruct.DLC)
{
for(i=0;i<=8;i++)
{
printf("%d\t", Rxbuf[i]);
}
}
HAL_Delay(1000);
}
}
评分
查看全部评分
没传上去
非常感谢!
谢谢您的回复
牙挺白牙挺白
支持一下楼主