uint8_t Rxflag=0;
uint16_t ucTemp;
uint16_t ucaRxBuf[256];
uint16_t usRxCount;
uint16_t a;
int main(void)
{
uint8_t i;
motor_init();
/* 初始化USART1串口 */
USARTx_Config();
NVIC_Configuration();
usRxCount = 0;
for(;;)
{
if(Rxflag)
{
if (usRxCount < sizeof(ucaRxBuf))
{
ucaRxBuf[usRxCount++] = ucTemp;
PWM_MOTOR1=ucTemp; /*将接收道德数据赋值给ccr寄存器*/
PWM_MOTOR2=ucTemp;
}
else
{
usRxCount = 0;
}
// 当接收到换行时认为接收到一个字符
if (ucTemp == 0x0A) /* 换行字符 */
{
Usart_SendStr_length( macUSARTx, ucaRxBuf, usRxCount );
//Usart_SendString();
usRxCount = 0;
}
Rxflag=0;
}
}
} |