金牌会员
- 积分
- 1467
- 威望
- 701
- 贡献
- 410
- 兑换币
- 428
- 注册时间
- 2014-1-6
- 在线时间
- 178 小时
|
小翔的abc没有d 发表于 2014-5-19 23:27
为什么代码都一样,可是依然不能显示正常波形,示波器依然只有一条线,无法成功输出波形,求大神帮忙解答啊 ... - /*
- * Description: 虚拟示波器校验码生成函数
- *
- * Data: 2014.5.8
- * Author: Liu
- */
- unsigned short CRC_CHECK(unsigned char *Buf, unsigned char CRC_CNT)
- {
- unsigned short CRC_Temp;
- unsigned char i,j;
- CRC_Temp = 0xffff;
- for (i=0;i<CRC_CNT; i++){
- CRC_Temp ^= Buf[i];
- for (j=0;j<8;j++) {
- if (CRC_Temp & 0x01)
- CRC_Temp = (CRC_Temp >>1 ) ^ 0xa001;
- else
- CRC_Temp = CRC_Temp >> 1;
- }
- }
- return(CRC_Temp);
- }
- /*
- * Description: 虚拟示波器输出函数
- *
- * Data: 2014.5.8
- * Author: Liu
- */
- void VisualScope_Output(float data1 ,float data2 ,float data3 ,float data4)
- {
- int temp[4] = {0};
- unsigned int temp1[4] = {0};
- unsigned char databuf[10] = {0};
- unsigned char i;
- unsigned short CRC16 = 0;
- temp[0] = (int)data1;
- temp[1] = (int)data2;
- temp[2] = (int)data3;
- temp[3] = (int)data4;
- temp1[0] = (unsigned int)temp[0] ;
- temp1[1] = (unsigned int)temp[1];
- temp1[2] = (unsigned int)temp[2];
- temp1[3] = (unsigned int)temp[3];
-
- for(i=0;i<4;i++)
- {
- databuf[i*2] = (unsigned char)(temp1[i]%256);
- databuf[i*2+1] = (unsigned char)(temp1[i]/256);
- }
-
- CRC16 = CRC_CHECK(databuf,8);
- databuf[8] = CRC16%256;
- databuf[9] = CRC16/256;
- for(i=0;i<10;i++)
- uart_putchar(UART3,databuf[i]);
- }
复制代码
|
|