SPI 통신 (2)

2016. 8. 11. 16:23 from MCU/ARM

SPI 실습 방법


실습 방법 :  USART와 SPI를 서로 연결해서 통신을 수행. USART1을 master, SPI1을 slave로 설정. USART는 synchronous와 ansynchronous둘 다 가능한데 synchronous mode를 사용하여 USART_CK 핀에서 clock을 공급할 수 있도록 한다. 


아래 그림은 SPI와 연결되는 모습을 개념도로 나타낸 그림이다.

UART통신에서 전송되는 data는 Start bit, Stop bit가 존재하고 있다. 하지만 SPI와 연결하는 경우에 Start bit, Stop bit에서는 클럭이 발생하지 말아야 한다. 이것은 실제 전송하려는 data가 아니기 때문이다.



CPOL CPHA


 CPOL은 Polarity를 말하고 CPHA는 Phase를 말한다. CPOL(polarity)데이터를 전송할 때 공급되는 클럭이 Idle 상태일 때 low일지 high일지 정할 수 있고, CPHA(phase)는 falling edge에 data를 읽고 쓸지 혹은 rising edge일 때 data를 읽고 쓸지 정할 수 있다. CPOL, CPHA 각 register의 값에 따라 data전송 방식은 아래와 같다.



 위 Diagram을 보면 Phase가 0이면 polarity에 상관 없이 첫 번째 edge(rising edge)에서 값을 읽고 Phase가 1이면 polarity에 상관 없이 두 번째 edge(falling edge)에서 값을 읽는다.


For CPOL = 0, the clock idles at logic zero. If CPHA = 0, data are read on the rising edge and change on the falling edge of SCK. If CPHA = 1, data are read on the falling edge and change on the rising edge of SCK.


For CPOL = 1, the clock idles at logic high. If CPHA = 0, data are read on the falling edge and change on the rising edge of SCK. If CPHA = 1, data are read on the rising edge and change on the falling edge of SCK.





 위 그림은 실제 MPU 6500 datasheet에 들어있는 SPI timing diagram 이다. SCLK를 보면 Idle 상태에서 1에 있고 첫 번째(falling) edge에서 아무것도 안하고(아마도 data change가 이루어질 듯) 두 번째(rising) edge에서 read data가 이루어지고 있다.




참고 : http://electronicdesign.com/microcontrollers/isolate-your-high-speed-spi-bus-despite-long-propagation-delays, ARM Cortex-M3 시스템 프로그래밍 완전정복2

'MCU > ARM' 카테고리의 다른 글

ADC independent DMA (2)  (0) 2016.08.14
ADC main feature(1)  (0) 2016.08.13
SPI 통신 (3)  (0) 2016.08.11
SPI 통신 (1)  (0) 2016.08.11
(*(volatile unsigned *))0x40021018 의미  (1) 2013.12.15
Posted by 나무길 :