Вт янв 29, 2019 19:34:38
{//настройка USART
//----------
//* Enable USART1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
/* NVIC Configuration */
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Configure the USART1 */
USART_InitTypeDef USART_InitStructure;
/* USART1 configuration ----------*/
/* USART1 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
- USART Clock disabled
- USART CPOL: Clock is active low
- USART CPHA: Data is captured on the middle
- USART LastBit: The clock pulse of the last data bit is not output to
the SCLK pin
*/
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
/* Enable USART1 */
USART_Cmd(USART1, ENABLE);
/* Enable the USART1 Receive interrupt: this interrupt is generated when the
USART1 receive data register is not empty */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
//----------
}
void USART1_IRQHandler(void)
{
/////////////////////////////////////////////////////////////////////////////////////////
if ((USART1->SR & USART_FLAG_RXNE) != (u16)RESET)
{
RXc = USART_ReceiveData(USART1);
RX_BUF[RXi] = RXc;
RXi++;
if (RXc != 13) {
if (RXi > RX_BUF_SIZE-1) {
clear_RXBuffer();
}
}
else {
RX_FLAG_END_LINE = 1;
}
//Echo
USART_SendData(USART1, RXc);
}
/////////////////////////////////////////////////////////////////////////////////////////
}
Чт янв 31, 2019 10:32:15
Чт янв 31, 2019 12:12:35
Чт янв 31, 2019 12:14:20
viewtopic.php?p=3559944#p3559944DENIS451 писал(а):Куда то исчезли два поста из этой темы!