minzisc 发表于 2024-1-13 10:19

RD8x3x串口

void delay(uint16_t nms)
{
      uint16_t i,j;
      for(i=0;i<nms;i++)
                for(j=0;j<10000;j++)
                ;
}
void Uart1_Init(unsigned int Freq,unsigned long int baud)
{
    P1CON&=0xf5;
    P1PH|=0x0A;
    OTCON|=0xc0;
    US1CON0=0x50;
    US1CON1=Freq*1000000/baud;
    US1CON2=(Freq*1000000/baud)>>8;
}

void Uart1_Send(int value)
{
    US1CON0=US1CON0&0xFD|0x02;
    US1CON3 = (uint8_t)value;
    while((US1CON0&0x02) == 0x00);
}

页: [1]
查看完整版本: RD8x3x串口