初级会员
- 积分
- 160
- 金钱
- 160
- 注册时间
- 2019-9-22
- 在线时间
- 43 小时
|
1金钱
定时器的函数
if(TIM_GetITStatus(TIM6,TIM_IT_Update)!=RESET)
{
count_ms++;//ms
MS_CNT_INC();
if(count_ms >= 1000)
{
CAN_Send_CCS_cur();
CAN_Send_CCS_input_vol();
CAN_Send_CCS_output_vol();
CAN_Send_CCS_temp_vol();
LED0 = !LED0;
SEC_CNT_INC();
count_s++;
count_ms = 0;
}
TIM_ClearITPendingBit(TIM6,TIM_IT_Update);
}
//发送恒流源电流
u8 CAN_Send_CCS_cur(void)
{
CanTxMsg TxMessage;
TxMessage.StdId = 0x00<<24;//标准帧
TxMessage.ExtId = (0x09<<24) + (0x00<<17) + (0x00<<16) + (0x00<<15) + (0x02<<8) + 62;//扩展帧
TxMessage.IDE = CAN_ID_EXT;
TxMessage.RTR = CAN_RTR_DATA;
TxMessage.DLC = 8;
TxMessage.Data[0] = 0x06;
TxMessage.Data[1] = 0x02;
TxMessage.Data[2] = 0x00;
TxMessage.Data[3] = 0xa6;
TxMessage.Data[4] = 0x41;
TxMessage.Data[5] = 0x28;
TxMessage.Data[6] = 0x00;
TxMessage.Data[7] = 0x00;
CAN_Transmit(CAN1, &TxMessage);
return 1;
}
//发送恒流源输入电压
u8 CAN_Send_CCS_input_vol(void)
{
CanTxMsg TxMessage;
TxMessage.StdId = 0x00<<24;//标准帧
TxMessage.ExtId = (0x09<<24) + (0x00<<17) + (0x00<<16) + (0x00<<15) + (0x02<<8) + 62;//扩展帧
TxMessage.IDE = CAN_ID_EXT;
TxMessage.RTR = CAN_RTR_DATA;
TxMessage.DLC = 8;
TxMessage.Data[0] = 0x06;
TxMessage.Data[1] = 0x02;
TxMessage.Data[2] = 0x00;
TxMessage.Data[3] = 0xa4;
TxMessage.Data[4] = 0x43;
TxMessage.Data[5] = 0x09;
TxMessage.Data[6] = 0x00;
TxMessage.Data[7] = 0x00;
CAN_Transmit(CAN1, &TxMessage);
return 1;
}
//发送恒流源输出电压
u8 CAN_Send_CCS_output_vol(void)
{
CanTxMsg TxMessage;
TxMessage.StdId = 0x00<<24;//标准帧
TxMessage.ExtId = (0x09<<24) + (0x00<<17) + (0x00<<16) + (0x00<<15) + (0x02<<8) + 62;//扩展帧
TxMessage.IDE = CAN_ID_EXT;
TxMessage.RTR = CAN_RTR_DATA;
TxMessage.DLC = 8;
TxMessage.Data[0] = 0x06;
TxMessage.Data[1] = 0x02;
TxMessage.Data[2] = 0x00;
TxMessage.Data[3] = 0xa5;
TxMessage.Data[4] = 0x42;
TxMessage.Data[5] = 0x48;
TxMessage.Data[6] = 0x00;
TxMessage.Data[7] = 0x00;
CAN_Transmit(CAN1, &TxMessage);
return 1;
}
//发送恒流源温度
u8 CAN_Send_CCS_temp_vol(void)
{
CanTxMsg TxMessage;
TxMessage.StdId = 0x00<<24;//标准帧
TxMessage.ExtId = (0x09<<24) + (0x00<<17) + (0x00<<16) + (0x00<<15) + (0x02<<8) + 62;//扩展帧
TxMessage.IDE = CAN_ID_EXT;
TxMessage.RTR = CAN_RTR_DATA;
TxMessage.DLC = 8;
TxMessage.Data[0] = 0x06;
TxMessage.Data[1] = 0x02;
TxMessage.Data[2] = 0x00;
TxMessage.Data[3] = 0xa8;
TxMessage.Data[4] = 0x42;
TxMessage.Data[5] = 0x20;
TxMessage.Data[6] = 0x00;
TxMessage.Data[7] = 0x00;
CAN_Transmit(CAN1, &TxMessage);
return 1;
}
|
最佳答案
查看完整内容[请看2#楼]
因为STM32只有3个发送邮箱,你一口气扔给它4个包.它装不下.你的程序又没有等待空邮箱.所以第4个包就丢了.
|