使用的51单片机,以下是出现问题的代码,请各位帮看看,结构体已在头文件里定义过:
#include "receive.h"
gRXBUFF gRxBuff;
uchar tempRx = 0; //临时接收变量
uchar rxCnt = 0; //接收计数器/指针
/*********************************************
FunctionName: UART
FunctionInfo: 52单片机的串口接收中断
Input: no
Output: no
注:兼容51 使用的定时器2定时器2做波特率发生器若改用51得注意
**********************************************/
void UART() interrupt 4
{
ES = 0; //暂时关闭串口中断允许位
RI = 0; //接收中断标志位 由软件清零
tempRx = SBUF;
gRxBuff.add = tempRx; //这样才正确
//(gRxBuff.add + sizeof(uchar)*8) = tempRx; //左值不正确-> left side of asn-op not an lvalue
//*( *(uchar)gRxBuff.add + rxCnt ) = tempRx; //左值不正确
//*( *(&gRxBuff.add) +rxCnt) = tempRx; //左值不正确
rxCnt++;
}
|
评论
|