在AVR STUDIO里编程,RS485 的发送函数,如在问题补充里,不过老是出现编译错误,请大家帮我看 是什么问题 10
voidUSART1_Send(void)//RS485发送函数{uinti;//uchartx_cBuffer1[100];tx_cBuffer1[0]=0x01;tx...
void USART1_Send(void) //RS485发送函数
{
uint i;
// uchar tx_cBuffer1[100];
tx_cBuffer1[0]=0x01;
tx_cBuffer1[1]=0x03;
tx_cBuffer1[2]=0x00;
tx_cBuffer1[3]=0x03;
tx_cBuffer1[4]=0x00;
tx_cBuffer1[5]=0x02;
tx_cBuffer1[6]=0x34;
tx_cBuffer1[7]=0x0b;
for(i=0;i<8;i++)
{
CTR_H; //RS485处于发送状态
while ( !(UCSR1A & (1<<UDRE1))) ;
UDR1 = tx_cBuffer1[i]; //接收到的数据发送到下位机
delay_ms(2);
}
CTR_L; //RS485处于接收状态
}
编译器提示出现的错误是:1../USART.c:235: error: 'buf' undeclared (first use in this function)
2.../USART.c:235: error: (Each undeclared identifier is reported only once
3。../USART.c:235: error: for each function it appears in.)
4../USART.c:256: error: expected identifier or '(' before '{' token 展开
{
uint i;
// uchar tx_cBuffer1[100];
tx_cBuffer1[0]=0x01;
tx_cBuffer1[1]=0x03;
tx_cBuffer1[2]=0x00;
tx_cBuffer1[3]=0x03;
tx_cBuffer1[4]=0x00;
tx_cBuffer1[5]=0x02;
tx_cBuffer1[6]=0x34;
tx_cBuffer1[7]=0x0b;
for(i=0;i<8;i++)
{
CTR_H; //RS485处于发送状态
while ( !(UCSR1A & (1<<UDRE1))) ;
UDR1 = tx_cBuffer1[i]; //接收到的数据发送到下位机
delay_ms(2);
}
CTR_L; //RS485处于接收状态
}
编译器提示出现的错误是:1../USART.c:235: error: 'buf' undeclared (first use in this function)
2.../USART.c:235: error: (Each undeclared identifier is reported only once
3。../USART.c:235: error: for each function it appears in.)
4../USART.c:256: error: expected identifier or '(' before '{' token 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询