Re: [問題] 關於mController的SPI

看板ASM (組合語言)作者 (Faint..)時間17年前 (2007/09/15 21:15), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串2/3 (看更多)
nRF2401 http://www.sparkfun.com/datasheets/RF/nRF2401rev1_1.pdf PRT4000 http://www.sunstare.com/zydlw/WXSFXP/WXSFZL/PTR4000.pdf HCS08 http://pdf1.alldatasheet.net/datasheet-pdf/view/120936/FREESCALE/MC9S08QG8.html nRF2401 ShockBurst™ Receive: MCU interface pins: CE, DR1, CLK1 and DATA (one RX channel receive) 1. Correct address and size of payload of incoming RF packages are set when nRF2401 is configured to ShockBurst™ RX. 2. To activate RX, set CE high. 3. After 200 ms settling, nRF2401 is monitoring the air for incoming communication. 4. When a valid package has been received (correct address and CRC found), nRF2401 removes the preamble, address and CRC bits. 5. nRF2401 then notifies (interrupts) the MCU by setting the DR1 pin high. 6. MCU may (or may not) set the CE low to disable the RF front end (low current mode). 7. The MCU will clock out just the payload data at a suitable rate (ex. 10 kbps). 8. When all payload data is retrieved nRF2401 sets DR1 low again, and is ready for new incoming data package if CE is kept high during data download. If the CE was set low, a new start up sequence can begin, see Figure 17. 用的RF是中國產品使用nRF2401的中文版.. 接收 1 MCU 首先通过通过配置模式将PTR4000 设为接收模式 2 MCU 设定CE=1 PTR4000 进入工作模式 3 当PTR4000 接收到数据与设置的本机地址一致且CRC 效验正确时通过DR1 输出高电平 DR1 可由MCU 查询或触发MCU 中断 4 MCU 可通过CLK1 DATA 读取接收到的数据数据长 而我的MCU在MOMI 15.2.2 MOSI — Master Data Out, Slave Data In When the SPI is enabled as a master and SPI pin control zero (SPC0) is 0 (not bidirectional mode), thispin is the serial data output. When the SPI is enabled as a slave and SPC0 = 0, this pin is the serial data input. If SPC0 = 1 to select single-wire bidirectional mode, and master mode is selected, this pin becomes the bidirectional data I/O pin (MOMI). Also, the bidirectional mode output enable bit determines whetherthe pin acts as an input (BIDIROE = 0) or an output (BIDIROE = 1). If SPC0 = 1 and slave mode is selected, this pin is not used by the SPI and reverts to being a general-purpose port I/O pin. 所以照他說的我用 SPC0 = 1;//bidirection MSTR = 1;//Master Selected BIDIROE = 0;//Input 問題在這邊... MCU input的時候CLK會不會自己變成input CLK 還是可以自己generate CLK收input data(nRF2401 要求 MCU 提供CLK) Output的時候我用Ocilliscope看都可以看到CLK跟data Input的時候有data但是CLK沒有 所以收不到東西 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.171.168.22

09/15 23:11, , 1F
你的設定看起來沒錯。clock不會變成input,你可能沒有啟
09/15 23:11, 1F

09/15 23:12, , 2F
動SPI的感覺。
09/15 23:12, 2F

09/15 23:14, , 3F
你要不要po一下你接收data的程式?
09/15 23:14, 3F
文章代碼(AID): #16wziBMN (ASM)
文章代碼(AID): #16wziBMN (ASM)