1、BRR--- bit RESET(置0) register //高16位无,低16位置1为0,不能写1
2 、BSRR--- bit SET(设置1或0) register //低16位设置1为0
BSRR:用于低16位的作用是让指定的IO口置1;而高16位的作用是让指定的IO口置0。
文章来源:https://www.toymoban.com/news/detail-504340.html
文章来源地址https://www.toymoban.com/news/detail-504340.html
static void IoUartTxd(IO_UART_STRUCT *uart)
{
if(uart->TxdByteCp < uart->TxdByte)
{
if(uart->TxdBit == 0)//起始位
{
uart->TxdCheck = 0;
uart->TxdPort->BRR = uart->TxdPin; //置低
}
else if(uart->TxdBit <= 8)//数据位
{
if(uart->TxdBuff[uart->TxdByteCp]&(1<<(uart->TxdBit-1)))
{
uart->TxdCheck++; //记录高电平个数
uart->TxdPort->BSRR = uart->TxdPin; //置高
}
else
{
uart->TxdPort->BRR = uart->TxdPin; //置低
}
}
else if(uart->Parity && uart->TxdBit <= 9) //校验位
{
if(uart->Parity == 1){if(uart->TxdCheck%2){uart->TxdPort->BRR = uart->TxdPin;}else{uart->TxdPort->BSRR = uart->TxdPin;}}//奇校验
if(uart->Parity == 2){if(uart->TxdCheck%2){uart->TxdPort->BSRR = uart->TxdPin;}else{uart->TxdPort->BRR = uart->TxdPin;}}//偶校验
}
else //停止位
{
uart->TxdPort->BSRR = uart->TxdPin;
}
if((++uart->TxdBit >= 10 && !uart->Parity) || uart->TxdBit >= 11){uart->TxdBit = 0; uart->TxdByteCp++;}
}
else if(uart->TxdByteCp > 0)
{
uart->TxdByte = 0;
uart->TxdByteCp = 0;
uart->Time->CR1 &= 0xfffe; // 失能
EXTI->IMR |= uart->ExitLine; // 开外部中断
}
}
到了这里,关于stm32的BRR寄存器和BSRR寄存器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!