블로그 이미지
안녕1999

카테고리

전체 (3067)
자바스크립트 (20)
안드로이드 (14)
WebGL (4)
변비 (17)
정치,경제 (35)
C언어,ARM (162)
컴퓨터(PC, Note Book, 윈.. (41)
전자회로, PCB (27)
유머,안웃긴,GIF,동영상 (118)
국부론60 (71)
모듈(PCB) (3)
건강 (2)
FreeCAD (25)
PADS (43)
퇴직,퇴사,구직,취업 활동 (3)
C# (86)
엑셀 (8)
워드 (0)
LabView (6)
레고 (30)
FPGA (0)
Total
Today
Yesterday

달력

« » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

공지사항

최근에 올라온 글

'USART_IT_RXNE'에 해당되는 글 1건

  1. 2016.09.06 STM32 UART 인터럽트
폴링방식 : 데이터 송수신이 끝날때까지 대기.(다른작업은 할 수 없음)

인터럽트를 사용해야하는 이유
----------------------------------
- UART는 매우 저속통신이라
  1바이트 송수신할때도 CPU는 많은 일을 할 수 있습니다.
  1바이트 송수신 끝날때까지 기다리는것은 너무 큰 손해입니다.
- 폴링방식으로 하면, 받은 데이터를 처리하는 동안에는 다른 데이터를 받을 수 없습니다.
  인터럽트 방식은 수신 버퍼를 만들고, 인터럽트 발생할때마다, 수신 버퍼에 넣고, 나중에 메인함수에서 처리합니다.
  폴링방식에 비해, 고속이며, 데이터를 놓치는 경우가 적습니다.(버퍼 크기에 좌우됨)

※인터럽트가 발생하면, CPU가 깨어납니다.

기본 설계
--------------
main()
{
초기화
while(1)
{
uart1_rx_proc();
CPU_Sleep();
}
}

void USART1_IRQHandler(void)
{
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)//데이터가 수신되었는가?
{
USART_ClearITPendingBit(USART1, USART_IT_RXNE);//데이터 수신비트 클리어
uart1_fifo_push_byte((USART_ReceiveData(USART1)) & 0x00FF);
}
}


  Polling Mode

  =============

  In Polling Mode, the UART communication can be managed by 10 flags:

     1. USART_FLAG_TXE : to indicate the status of the transmit buffer register

     2. USART_FLAG_RXNE : to indicate the status of the receive buffer register

     3. USART_FLAG_TC : to indicate the status of the transmit operation

     4. USART_FLAG_IDLE : to indicate the status of the Idle Line             

     5. USART_FLAG_CTS : to indicate the status of the nCTS input

     6. USART_FLAG_LBD : to indicate the status of the LIN break detection

     7. USART_FLAG_NE : to indicate if a noise error occur

     8. USART_FLAG_FE : to indicate if a frame error occur

     9. USART_FLAG_PE : to indicate if a parity error occur

     10. USART_FLAG_ORE : to indicate if an Overrun error occur 





     1. USART_IT_TXE : specifies the interrupt source for the Tx buffer empty 

                       interrupt. 

     2. USART_IT_RXNE : specifies the interrupt source for the Rx buffer not 

                        empty interrupt.

     3. USART_IT_TC : specifies the interrupt source for the Transmit complete 

                       interrupt. 

     4. USART_IT_IDLE : specifies the interrupt source for the Idle Line interrupt.             

     5. USART_IT_CTS : specifies the interrupt source for the CTS interrupt. 

     6. USART_IT_LBD : specifies the interrupt source for the LIN break detection

                       interrupt. 

     7. USART_IT_PE : specifies the interrupt source for the parity error interrupt. 

     8. USART_IT_ERR :  specifies the interrupt source for the errors interrupt.

 



Posted by 안녕1999
, |

최근에 달린 댓글

글 보관함