新唐M0驱动485
驱动vp3082,发送函数,函数开始485使能端设为1不能发送数据,,出函数时设为0,,之后进入主函数能接收485数据,接受正常。当函数开始485使能端设为0,出函数时使能设为1,能发送数据,发送数据正确。但是进入主函数不能接受数据。不知道怎么回事??? void UART0_beginSend(volatile unsigned char *UART_Transmit_Buffer , unsigned char UART_TransmitCount){
uint8_t UART0_sendPosi= 0 , k;
// UART0_set_receive() ;
UART0_set_transimit(); //P0.3置1,设为发送
for(k=0;k<100;k++);
do
{
// for(k=0;k<20;k++);
UA0_THR = UART_Transmit_Buffer ;
UART0_sendPosi ++ ;
while ( ( UA0_FSR&TX_EMPTY) != 0x00 ) ; //check Tx Empty
// for(k=0;k<20;k++);
}
while(UART0_sendPosi < UART_TransmitCount ) ;
for(k=0;k<200;k++);
UART0_set_receive() ; //P0.3置0,设为接收
// UART0_set_transimit();
} Sensor_IO_Init(); /* Sensor I/O initialization */
// TCSR0 |= CEN; /* Enable Timer0 */
UART0_beginSend(UART0_Receive_Buffer, 4); //UART0 test
// UART1_beginSend(UART1_Receive_Buffer, 4);
while( 1 )
{
if(UART0_Receive_Buffer!=0)
{
UART0_Receive_Buffer=0;
UART0_set_receive();
UART0_ReceCount=0;
UART0_beginSend(UART0_Receive_Buffer, 4);
}
}
页:
[1]