STM32F3 硬件I2C 驱动OLED 求助!!
STM32F303使用定时器触发双ADC常规同步采样模式
哪位大哥传下STM32F334 Nucleo的工程模板给我下
STM32F334 不能串口下载
关于STM32F334的HRTIM分辨率问题
STM32F303+LCD1602程序问题,不只为什么点不亮?
STM32F334的ADC使用问题
STM32F334 HRTIM形成移相全桥波形问题
有用过STM32F373VC的板子么 iic 例程不好使
STM32F3 ADC外部触发采样达不到7.2MSPS
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);
}
}
评分
查看全部评分
没传上去
非常感谢!
谢谢您的回复
牙挺白牙挺白
支持一下楼主
大家对上述代码有何指正的不要吝啬,都提出来