본문 바로가기
임베디드.일렉트로닉스/nRF52

nRF52. SPI

by i.got.it 2019. 10. 25.

 

 

nRF52 SPI 

 

 

Features

 

SPI 수량 : nRF52840 의 경우 SPI master 로 사용시 4개, spi slave 로 사용시 3개. 

 

 

nRF52840 SPI 최대 통신 속도 및 SPI 클럭  

SPIM3 최대통신속도 32Mbps . 주의 : 32Mbps 는 SPIM3 에서만 지원되는 사양.

최대 통신 속도는 SPI 클럭으로 결정되는데 , 데이트 시트 전기사양 부분을 보면 SPIM3을 비롯한 모든 nRF52840 의  SPI 클럭 최대 주파수는 8MHz 로 명시되어있는데,  SPI 클럭 최대 8MHz 라면 통신 속도  32Mbps 는 불가능한데  32Mbps 가능하다고 표현하고 있음. 

 

from : http://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.0.pdf   의 페이지 388 에 있는 SPIM 전기 사양 부분 상세히 보자  SCK Period 최소값이 125 nsec 이므로 주파수로는 8MHz 에 해당한다. 그런데 Bit rates 에서 최대 32MBps 된다고 기록되어있다.  그리고 그 아래에 고속 통신 가능할려면   GPIO 핀  High Drive 요구될 수도 있다고되어있음. must 도 아니고 may? 

 

사족

아...또 빡대가리가 데이터 시트 작성했나봄.  혹은 동일 품번 칩인데 revision 에 따라 특성이 달라서 지들도 혼선 일으키고 있는 것 같기도 함. 

 

nRF5280 SPI 안전 설계 기준

안전하게 설계하려면 nRF52840 의 모든 SPI (마스터든 슬레이브든 ) 클럭 최대  8MHz 이하로 사용하면 됨.

고속 SPI Master 요구되는 경우 SPIM3 의 안정 통신 가능한 속도 시험 검사 직접 수행 한 결과 보증되는 최고 속도로 확인 과정 거쳐야 한다.  예 : 30일 연속 온도 범위 0도 ~ 80도 고속 통신 과정에서  오류 0회 등의 조건 만족.  특히 연속 통신 중엔 오류 없었던 것도 초기 첫 통신 시점에 오류가 많이 발생하므로 이런 지점 모두 체크되어야 함.  

  

 

 

 

 

 

SPI Master . Function Block 

from : http://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.0.pdf  page 367 

 

SPIM - SPI Master with Easy DMA 

 

 

 

 

 

 

 

 

 

 

 

SPIS - SPI slave with EasyDMA

from : http://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.0.pdf  page 389 

 

- SPIS 는 기본 EasyDMA 적용되어 작동하므로 SPI master 처럼 EasyDMA 활용 위한 별도 처리 필요없음. 

- ultra low power 

- SPI mode0,1,2,3 지원. 레지스터 CONFIG 의 CPOL, CPHA 에서 설정. 

-- SPI Mode 0 : CPOL = 0 (Leading), CPHA = 0 (Active High)

-- SPI Mode 1 : CPOL = 0 (Leading), CPHA = 1 (Active Low) 

-- SPI Mode 2 : CPOL = 1 (Trailing), CPHA = 0 (Active High)

-- SPI Mode 3 : CPOL = 1 (Trailing), CPHA = 1 (Active Low)

 

 

 

 

 

 

 

SPIS Pin configuration 

1. SPI 의 핀 설정 레지스터. 

 

PSEL.CSN : CSN 

PSEL.SCK : SCK 

PSEL.MOSI : MOSI 

PSEL.MISO : MISO 

 

2. SPI slave 가 disabled 상태에서만 위 레지스터 설정해야한다. 

3. SPI slave 용으로 사용되는 핀의 입출력방향은 모두 Input 으로 설정(MISO 마저도 Input 으로 설정)한 이후에 SPI slave enable 시켜야한다. 

4. MISO 핀은 CSN 으로 선택되지 않은 상태에서는 high impedance 상태이다.  

 

 

 

Errata - SPI  

- 칩 출하 이후 발견된 오류 및 조치법들. 

- ERRATA 웹페이지: https://infocenter.nordicsemi.com/topic/errata_nRF52840_Rev2/ERR/nRF52840/Rev2/latest/err_840_new.html

 

Errta 214 SPIS : Incorrect data transferred. 

- 상황 : CSN low 인 상태에서 SPIS 를 disabled 시킨경우. 

- 오류 : 신규 SPI 전송시 첫바이트에 이전 전송시의 바이트가 전송되어 오류 발생함. 

- 조치 : After disabling the SPISn instance (writing SPISn->ENABLE = SPIS_ENABLE_ENABLE_Disable), apply the following code:

 

*(volatile uint32_t *) (NRF_SPISn_BASE + 0xA4ul) = 1ul;

*(volatile uint32_t *) (NRF_SPISn_BASE + 0xACul) = 1ul;

 

 

 

 

nRF52840 최고속도 얼마냐 는 질문에 답변 달린거 보면 SPIM Instance 3 는 34MHz 까지 된다는 답변. -2018년 .

 

nRF52840, 16 MHz or 32 MHz SPI? - Nordic DevZone

 

devzone.nordicsemi.com

 

SPIS 첫통신 1 비트 시프트 증상 있다는 질문. 

 

SPIS data shift on first transfer - Nordic DevZone

 

devzone.nordicsemi.com

위 링크의 질문자와 동일한 오류 증상 경험했었는데, 나의 경우엔 STM32 의 오류로 결론 났었음. 상세 아래 링크. 

 

STM32. 버그 해결. SPI 통신. 첫 SPI 송수신 데이터 비트 밀림 . 해결방법.

개요 버그 요점 : STM32 를 SPI Master 로 설정하여 SPI Slave 와 통신시 STM32 부팅후 첫 SPI 통신시 비트 밀림 오류 있음. 버그 상황 상세 환경. STM32 라이브러리 버전 : STM32Cube FW_L4 V1.14.0 (2020년 1월..

igotit.tistory.com

 

 

SPI Code example 

 

- SPI Master 

The SPI Master Example demonstrates the use of the SPI or SPIM peripheral. It uses the SPI master driver. The application executes SPI transactions every 200 ms and toggles the LED when the transfer is completed.

 

 

 

nRF5 SDK v17.1.0: SPI Master Example

The SPI Master Example demonstrates the use of the SPI or SPIM peripheral. It uses the SPI master driver. The application executes SPI transactions every 200 ms and toggles the LED when the transfer is completed. If you connect one board that runs the SPI

infocenter.nordicsemi.com

 

 

- DMA 기반 SPI Master 통신. 

The nrfx SPI Master Example demonstrates the use of the SPIM peripheral with extended features. It uses the SPIM driver. 

 

nRF5 SDK v17.1.0: nrfx SPI Master Example

The nrfx SPI Master Example demonstrates the use of the SPIM peripheral with extended features. It uses the SPIM driver. The application executes SPIM transactions every 200 ms and toggles the LED when the transfer is completed. If you connect the board th

infocenter.nordicsemi.com

 

- SPI slave Example

 

The SPI Slave Example demonstrates the use of the SPIS peripheral. It uses the SPIS driver - legacy layer.

 

 

nRF5 SDK v17.1.0: SPI Slave Example

The SPI Slave Example demonstrates the use of the SPIS peripheral. It uses the SPIS driver - legacy layer. In the main loop, the application prepares the SPIS for a transfer and waits until the transfer is completed. Every time a transfer is completed, the

infocenter.nordicsemi.com

 

연관 

기초 지식  SPI Mode 이해 . https://igotit.tistory.com/2088

 

SPI mode 4종. CPOL, CPHA

SPI Mode 4종. SPI 통신 규격의 CPOL(0, 1) , CPHA(0, 1) 상태에 따라 4종의 SPI mode 가 있다. SPI mode 0 : CPOL = 0 , CPHA = 0 SPI mode 1 : CPOL = 0 , CPHA = 1 SPI mode 2 : CPOL = 1 , CPHA = 0 SPI mode..

igotit.tistory.com

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

상위 정리글

 

https://igotit.tistory.com/244 의 nRF52

 

STM32. nRF52. ESP32. EFM8. EFM32. PSoC 활용 정리.

STM32. nRF52. ESP32. EFM8. EFM32. PSoC 총정리 제조사 칩 주요특징 실리콘랩 8bit MCU EFM8 시리즈 32bit EFM32 시리즈 EFM8 싸다. STM STM32 . 최고 항상 만족. Cypress pSoC pSoC6 은 기대해볼만. NORDIC nRF5..

igotit.tistory.com

 

 

 

 


첫 등록 : 2019.01.13

최종 수정 : 2023.08.12

단축 주소 : https://igotit.tistory.com/2048


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5