stm32的BRR寄存器和BSRR寄存器

stm32的BRR寄存器和BSRR寄存器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

大家好,我是讯享网,很高兴认识大家。

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。

 

 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; // 开外部中断 } }
讯享网

小讯
上一篇 2025-03-27 23:15
下一篇 2025-01-06 12:17

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/118170.html