完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,首先,我是一个新手,想把nrf24+添加到我的16f88中,没有16F图片的图书馆。(我真的搜索了大约25-30天)我的项目是在Arduino和16F88之间建立连接。我使用的是XC8编译器。阿杜诺代码还行,但你能帮我做16F88吗?我想要的是从16F88到ARDUNO发送“1”和“0”。没有复杂的图书馆我能做到吗?谢谢。
以上来自于百度翻译 以下为原文 Hi, Firstly, I'm a newbie and trying to add nrf24+ to my 16f88 , there is no any library for 16F pics. (I really googled it about 25-30days) My project is creating a connection between Arduino and 16F88. I'm using the xc8 complier. Arduino codes are OK but can you help me for the 16f88 please ? All I want is send "1" and "0" from 16F88 to Arduino thats it. Can I do it without complicated libraries? Thanks. |
|
相关推荐
19个回答
|
|
为什么这么老的照片?C还是汇编程序?在这个论坛上应该有一些C代码…
以上来自于百度翻译 以下为原文 Why such an old PIC? C or assembler anyway? There should be some C code on this forum... |
|
|
|
使用C,我发现了一些C代码,但是它们不起作用。我可以不用长的图书馆吗?我不需要使用RX模式。我只需要发送1位数字。就是这样。
以上来自于百度翻译 以下为原文 Using C , I found some C codes but they're not working. Can I do it without any long library ? I dont need to use RX mode. I just need to send 1 digit. That's it. |
|
|
|
如果你不显示你尝试的代码,那么有点困难。
以上来自于百度翻译 以下为原文 It's a bit hard to suggest what the problem might be if you don't show the code you tried. |
|
|
|
http://www. eDabal.com /thig324244. HTMLI正在尝试这个。更改C端口为B,但仍然不工作。有没有办法轻松发送“1”和“0”?只想使用TX模式,谢谢你的回复。
以上来自于百度翻译 以下为原文 http://www.edaboard.com/thread328244.html I'm trying this one. Changed C ports as B. But still not working. Is there any way to send "1" and "0" easily? Just want to use TX mode. Thanks for your replies. |
|
|
|
嗯,你不能简单地从PORTC变成B.。你的照片上的SPI在哪里?顺便说一下,我更喜欢与那些NRF设备交谈的SW(BIT)代码。它更灵活…
以上来自于百度翻译 以下为原文 Mmmm, you can't simply change from PORTC to B... where is the SPI on your PIC? By the way, I prefer SW (bit-banged) code for talking to those nRF devices... it's more flexible... |
|
|
|
你说得对。我能用SW快速地做吗?这是最简单的方法吗?
以上来自于百度翻译 以下为原文 You're right. Can I do it fastly with SW ? Is this the easiest way ? |
|
|
|
获取NFR24+PDF,一切都在那里。你想详细研究一下。不过我不会用8位来写。为这个芯片写一个库已经完成了。如果你真的尝试过,你会发现你需要读和写。考虑到芯片能做什么,你最终会得到一个大的头。如果你发送一些数据,你要确保它是在另一端接收到的。您需要重试、校验和等。您还需要设置SPI。只要从字节中知道一点就可以了。
以上来自于百度翻译 以下为原文 Get the nrf24+ pdf, everything is in there. You'll want to study that in detail. I wouldn't write that in 8bit though. It is a completed task writing a library for that chip. If you do attempt it, you will find that you need both reading and writing anyway. You'll end up with a large header considering what the chip can do. If you send some data, you'll want to make sure that it was received at the other end. You'll need retries, checksums etc. You'll need SPI set as well. As long as you know a bit from a byte you'll be fine. |
|
|
|
我不会咬它,让SPI做它,毕竟,它是一个SPI设备,它释放了CPU。
以上来自于百度翻译 以下为原文 I wouldn't bit bang it, let spi do it, after all, it is a spi device and it frees up the cpu. |
|
|
|
我实际上来自“老”2401,你必须在BangBang.在这个例子中,HW SPI可能确实被使用,但是当设备“有些奇怪”时,我仍然喜欢SW。如果需要的话,也可以使用PIN。
以上来自于百度翻译 以下为原文 I actually came from "old" 2401 where you had to bitbang. In this one, HW SPI may be used indeed, but I still prefer SW when the devices are "somewhat strange". And for pin-remappability too, if needed. |
|
|
|
open_SPI1(无符号int MOSI_SDO_RPn,无符号int MISO_SDI_RPn,无符号int SCK_RPn,uint SS_RPn);int init_wifi(int SPIn,volatile无符号int*CSN_LAT,int CSN_Pin,volatile无符号int*CE_LAT,int CE_Pin,volatile无符号int*IRQ_LAT,int IRQ_Pin);S不固定于函数。
以上来自于百度翻译 以下为原文 open_SPI1 (unsigned int MOSI_SDO_RPn, unsigned int MISO_SDI_RPn, unsigned int SCK_RPn, uint SS_RPn); int init_wifi (int SPIn, volatile unsigned int *CSN_LAT, int CSN_Pin, volatile unsigned int *CE_LAT, int CE_Pin, volatile unsigned int *IRQ_LAT, int IRQ_Pin); I always initialize devices where the pins are not fixed to the function. |
|
|
|
请给我一些例子代码好吗?我需要更多关于写图书馆的信息。没有长图书馆,有没有办法?这次我想用我的16F88做这件事,但是你下次会给我推荐哪些照片呢?谢谢你的回复
以上来自于百度翻译 以下为原文 Can you give me some example codes please. I need more information about writing a library. Is there any way to do it without a long library ? I want to do it with my 16F88 this time but which pics do you suggest to me next time ? Thanks for replies |
|
|
|
为此,你确实需要一个很长的图书馆,真的没有捷径。我已经列出了包含的文件。你下载了pdf并研究了这个小芯片使用的寄存器吗?大约是80页的pdf。编写库就像一组没有main的外部函数/consts/var。尝试编写一些基本的东西,比如添加两个数字和与main共享一些变量。一旦编译,将整个library.X包含到项目Library文件夹中。或者只包含一个对象。如果你写了很多函数。为每个函数/vars/consts创建新文件,否则编译器将包括所有内容(如果它是一个大文件)。**这是我的C文件和ASM。
以上来自于百度翻译 以下为原文 For this, you do need a long library, there really is no short cut. I have listed the include files. Did you download the pdf and study the registers this little chip uses? It is roughly an 80 page pdf. Writing a library is like a group of external functions/consts/vars without a main() Try writing something basic like adding two numbers and sharing some variables with main. Once compiled, include the whole library .X into your project Library folder. Or just one object .o. *** If you your writing many funcs. create new files for each function/vars/consts otherwise the compiler will include everything if it is one big file. *** This is my include c file/* * File: WIFILib2.h * Author: Marty * * Created on 12 January 2014, 22:14 */ //---------------------------------------------------- #ifndef WIFILIB2_H #define WIFILIB2_H #ifdef __cplusplus extern "C" { #endif //---------------------------------------------------- #include //---------------------------------------------------- //COMMAND #define R_REGISTER 0x00 #define W_REGISTER 0x20 #define ACTIVATE 0x50 #define R_RX_PAYLOAD 0x61 #define W_TX_PAYLOAD 0xA0 #define FLUSH_TX 0xE1 #define FLUSH_RX 0xE2 #define REUSE_TX_PL 0xE3 #define R_RX_PL_WID 0x60 #define W_ACK_PAYLOAD 0xA8 #define W_TX_PAYLOAD_NOACK 0xB0 #define _NOP 0xFF //---------------------------------------------------- //REGISTER #define CONFIG 0x00 #define EN_AA 0x01 #define EN_RXADDR 0x02 #define SETUP_AW 0x03 #define SETUP_RETR 0x04 #define RF_CH 0x05 #define RF_SETUP 0x06 #define STATUS 0x07 #define OBSERVE_TX 0x08 #define RPD 0x09 #define CD 0x09 #define RX_ADDR_P0 0x0A #define RX_ADDR_P1 0x0B #define RX_ADDR_P2 0x0C #define RX_ADDR_P3 0x0D #define RX_ADDR_P4 0x0E #define RX_ADDR_P5 0x0F #define TX_ADDR 0x10 #define RX_PW_P0 0x11 #define RX_PW_P1 0x12 #define RX_PW_P2 0x13 #define RX_PW_P3 0x14 #define RX_PW_P4 0x15 #define RX_PW_P5 0x16 #define FIFO_STATUS 0x17 #define DYNPD 0x1C #define FEATURE 0x1D //---------------------------------------------------- //00 CONFIG BITS #define CONFIG_MASK_RX_DR 6 #define CONFIG_MASK_TX_DS 5 #define CONFIG_MASK_MAX_RT 4 #define CONFIG_EN_CRC 3 #define CONFIG_CRC0 2 #define CONFIG_PWR_UP 1 #define CONFIG_PRIM_RX 0 //---------------------------------------------------- //01 ENABLE AA BITS #define EN_AA_ENAA_P5 5 #define EN_AA_ENAA_P4 4 #define EN_AA_ENAA_P3 3 #define EN_AA_ENAA_P2 2 #define EN_AA_ENAA_P1 1 #define EN_AA_ENAA_P0 0 //---------------------------------------------------- //02 ENABLE RX ADDRESS BITS #define EN_RXADDR_P5 5 #define EN_RXADDR_P4 4 #define EN_RXADDR_P3 3 #define EN_RXADDR_P2 2 #define EN_RXADDR_P1 1 #define EN_RXADDR_P0 0 //---------------------------------------------------- //04 AUTO RETRANSMISSION BITS #define SETUP_RETR_ARD 4 #define SETUP_RETR_ARC 0 //---------------------------------------------------- //06 RF SETUP BITS #define RFSETUP_CONT_WAVE 7 #define RFSETUP_RF_DR_LOW 5 #define RFSETUP_PLL_LOCK 4 #define RFSETUP_RF_DR_HIGH 3 #define RFSETUP_RF_PWR 1 //---------------------------------------------------- //07 STATUS BITS #define STATUS_RX_DR 6 #define STATUS_TX_DS 5 #define STATUS_MAX_RT 4 #define STATUS_RX_P_NO 1 #define STATUS_TX_FULL 0 //---------------------------------------------------- //08 OBSERVE TX BITS #define OBSERVE_PLOS_CNT 4 #define OBSERVE_ARC_CNT 0 //---------------------------------------------------- //17 FIFO STATUS BITS #define FIFO_STATUS_TX_REUSE 6 #define FIFO_STATUS_TX_FULL 5 #define FIFO_STATUS_TX_EMPTY 4 #define FIFO_STATUS_RX_FULL 1 #define FIFO_STATUS_RX_EMPTY 0 //---------------------------------------------------- //1C DYNPD BITS #define DYNPD_P5 5 #define DYNPD_P4 4 #define DYNPD_P3 3 #define DYNPD_P2 2 #define DYNPD_P1 1 #define DYNPD_P0 0 //---------------------------------------------------- //1D FEATURE BITS #define FEATURE_EN_DPL 2 #define FEATURE_EN_ACK_PAY 1 #define FEATURE_EN_DYN_ACK 0 //---------------------------------------------------- //ERROR CODES #define E_OK 0 #define E_SPIX -1 #define E_SPI_MODULE -2 #define E_NULL_ARGUMENT -3 #define E_NULL_PIPENAME -4 #define E_NULL_ADDRESS -5 #define E_PAYLOAD_BUFFER_NULL -6 #define E_PIPE_NUMBER -7 #define E_PIPENAME_LENGTH -8 #define E_PIPE_MASK -9 #define E_ADDRESS_LENGTH -10 #define E_ILLEGAL_CHARACTER -11 #define E_REGISTER_INVALID -12 #define E_ADDRESS_TAKEN -13 #define E_ADDRESS_NOT_FOUND -14 #define E_DUPLICATE_PIPE -15 #define E_FEATURE_NOT_AVAIL -16 #define E_PAYLOAD_SIZE -17 #define E_PAYLOAD_W_FULL -18 #define E_PAYLOAD_R_EMPTY -19 #define E_CHANNEL -20 #define E_MSBOF2TO5 -21 #define E_PIPE_NOT_AVAIL -22 #define E_RETRY -23 #define E_DELAY -24 #define E_PAYLOAD_W_EMPTY -25 #define E_DATA_RATE -26 #define E_POWER -27 #define E_RETRY_TX -28 #define E_RETRY_MAX -29 //---------------------------------------------------- //setmode, getmode //#define WIFI_STANDBY_I 0 //#define WIFI_STANDBY_II 1 //#define WIFI_TX 2 //#define WIFI_RX 3 //#define WIFI_POWER_DOWN 4 //---------------------------------------------------- //#define reuse_wifi read_wifi(REUSE_TX_PL) //---------------------------------------------------- extern int RETRY_CNT; //trasmit_wait //---------------------------------------------------- extern void powerdown (), receive (), reset_observe (bool Flush_Transmit, bool Flush_Receive); extern int ack_wifi (), addr_width (int Width), close_pipe (const char *PipeName), close_pipe_mask (int PipeMask), drop_payload (), //or rxflush1() get_channel (), getname_pipe (int Pipe, char *PipeName), get_addr_width (), get_payload_size (int *Pipe), get_retry (int *MicroSeconds), //init_wifi (WIFIPort_t *W), init_wifi (int SPIn, volatile unsigned int *CSN_LAT, int CSN_Pin, volatile unsigned int *CE_LAT, int CE_Pin, volatile unsigned int *IRQ_LAT, int IRQ_Pin), more (), name_pipe (int Pipe, const char *PipeName), open_pipe (const char *PipeName), open_pipe_mask (int PipeMask), read_payload (void *Buffer, int *ReturnPipeNumber), reada_wifi (int Register, char *Data), read_wifi (int Register), rxflush (), rxflush1 (), //or drop_payload() set_channel (int Channel), set_datarate (int DataRate, int Power_Output), set_retry (int Retries, int MicroSeconds), set_payload_size (const char *PipeName, int Length), transmit (const char *Address), transmit_wait (const char *Address, int Re_tries), transmit_waitdr (const void *TXBuffer, int Len, const char *Address, int Re_tries, void *RXBuffer, int *Pipe), transmit_waitr (const char *Address, int Re_tries, void *Buffer, int *Pipe), txflush (), write_ack (const void *Buffer, int Len), //or write_payload write_nack (const void *Buffer, int Len), write_pack (const char *PipeName, const void *Buffer, int Len), write_pack_p (int Pipe, const void *Buffer, int Len), write_payload (const void *Buffer, int Len), //or write_ack writea_wifi (int Register, const char *Data), write_wifi (int Register, int Data); //---------------------------------------------------- //UTILITY extern void list_pipes (), list_wifi (), list2_wifi (); extern const char *list_error (int ErrNo, bool LongDescription); extern int bigdata_transfer (const char *Address, const void *Buffer, unsigned int Len), list_status (); extern unsigned int bigdata_receive (void *Buffer, int *Pipe); extern unsigned long ping (int Channel, const char *Address, int *Received, int *Tries); //---------------------------------------------------- #ifdef __cplusplus } #endif #endif /* WIFILIB2_H */ //---------------------------------------------------- And asm..ifndef WIFILIB2 .equiv WIFILIB2,1 ;---------------------------------------------------- ;COMMAND .equiv R_REGISTER, 0x00 .equiv W_REGISTER, 0x20 .equiv ACTIVATE, 0x50 .equiv R_RX_PAYLOAD, 0x61 .equiv W_TX_PAYLOAD, 0xA0 .equiv FLUSH_TX, 0xE1 .equiv FLUSH_RX, 0xE2 .equiv REUSE_TX_PL, 0xE3 .equiv R_RX_PL_WID, 0x60 .equiv W_ACK_PAYLOAD, 0xA8 .equiv W_TX_PAYLOAD_NOACK, 0xB0 .equiv _NOP, 0xFF ;---------------------------------------------------- ;REGISTER .equiv CONFIG, 0x00 .equiv EN_AA, 0x01 .equiv EN_RXADDR, 0x02 .equiv SETUP_AW, 0x03 .equiv SETUP_RETR, 0x04 .equiv RF_CH, 0x05 .equiv RF_SETUP, 0x06 .equiv STATUS, 0x07 .equiv OBSERVE_TX, 0x08 .equiv RPD, 0x09 .equiv CD, 0x09 .equiv RX_ADDR_P0, 0x0A .equiv RX_ADDR_P1, 0x0B .equiv RX_ADDR_P2, 0x0C .equiv RX_ADDR_P3, 0x0D .equiv RX_ADDR_P4, 0x0E .equiv RX_ADDR_P5, 0x0F .equiv TX_ADDR, 0x10 .equiv RX_PW_P0, 0x11 .equiv RX_PW_P1, 0x12 .equiv RX_PW_P2, 0x13 .equiv RX_PW_P3, 0x14 .equiv RX_PW_P4, 0x15 .equiv RX_PW_P5, 0x16 .equiv FIFO_STATUS, 0x17 .equiv DYNPD, 0x1C .equiv FEATURE, 0x1D ;---------------------------------------------------- ;00 CONFIG BITS .equiv CONFIG_MASK_RX_DR, 6 .equiv CONFIG_MASK_TX_DS, 5 .equiv CONFIG_MASK_MAX_RT, 4 .equiv CONFIG_EN_CRC, 3 .equiv CONFIG_CRC0, 2 .equiv CONFIG_PWR_UP, 1 .equiv CONFIG_PRIM_RX, 0 ;---------------------------------------------------- ;01 ENABLE AA BITS .equiv EN_AA_ENAA_P5, 5 .equiv EN_AA_ENAA_P4, 4 .equiv EN_AA_ENAA_P3, 3 .equiv EN_AA_ENAA_P2, 2 .equiv EN_AA_ENAA_P1, 1 .equiv EN_AA_ENAA_P0, 0 ;---------------------------------------------------- ;02 ENABLE RX ADDRESS BITS .equiv EN_RXADDR_P5, 5 .equiv EN_RXADDR_P4, 4 .equiv EN_RXADDR_P3, 3 .equiv EN_RXADDR_P2, 2 .equiv EN_RXADDR_P1, 1 .equiv EN_RXADDR_P0, 0 ;---------------------------------------------------- ;04 AUTO RETRANSMISSION BITS .equiv SETUP_RETR_ARD, 4 .equiv SETUP_RETR_ARC, 0 ;---------------------------------------------------- ;06 RF SETUP BITS .equiv RFSETUP_CONT_WAVE, 7 .equiv RFSETUP_RF_DR_LOW, 5 .equiv RFSETUP_PLL_LOCK, 4 .equiv RFSETUP_RF_DR_HIGH, 3 .equiv RFSETUP_RF_PWR, 1 ;---------------------------------------------------- ;07 STATUS BITS .equiv STATUS_RX_DR, 6 .equiv STATUS_TX_DS, 5 .equiv STATUS_MAX_RT, 4 .equiv STATUS_RX_P_NO, 1 .equiv STATUS_TX_FULL, 0 ;---------------------------------------------------- ;08 OBSERVE TX BITS .equiv OBSERVE_PLOS_CNT, 4 .equiv OBSERVE_ARC_CNT, 0 ;---------------------------------------------------- ;17 FIFO STATUS BITS .equiv FIFO_STATUS_TX_REUSE, 6 .equiv FIFO_STATUS_TX_FULL, 5 .equiv FIFO_STATUS_TX_EMPTY, 4 .equiv FIFO_STATUS_RX_FULL, 1 .equiv FIFO_STATUS_RX_EMPTY, 0 ;---------------------------------------------------- ;1C DYNPD bits .equiv DYNPD_P5, 5 .equiv DYNPD_P4, 4 .equiv DYNPD_P3, 3 .equiv DYNPD_P2, 2 .equiv DYNPD_P1, 1 .equiv DYNPD_P0, 0 ;---------------------------------------------------- ;1D FEATURE BITS .equiv FEATURE_EN_DPL, 2 .equiv FEATURE_EN_ACK_PAY, 1 .equiv FEATURE_EN_DYN_ACK, 0 ;---------------------------------------------------- ;setmode, getmode ;.equiv WIFI_STANDBY_I, 0 ;.equiv WIFI_STANDBY_II, 1 ;.equiv WIFI_TX, 2 ;.equiv WIFI_RX, 3 ;.equiv WIFI_POWER_DOWN, 4 ;---------------------------------------------------- ;ERROR CODES .equiv E_OK, 0 .equiv E_SPIX, -1 .equiv E_SPI_MODULE, -2 .equiv E_NULL_ARGUMENT, -3 .equiv E_NULL_PIPENAME, -4 .equiv E_NULL_ADDRESS, -5 .equiv E_PAYLOAD_BUFFER_NULL, -6 .equiv E_PIPE_NUMBER, -7 .equiv E_PIPENAME_LENGTH, -8 .equiv E_PIPE_MASK, -9 .equiv E_ADDRESS_LENGTH, -10 .equiv E_ILLEGAL_CHARACTER, -11 .equiv E_REGISTER_INVALID, -12 .equiv E_ADDRESS_TAKEN, -13 .equiv E_ADDRESS_NOT_FOUND, -14 .equiv E_DUPLICATE_PIPE, -15 .equiv E_FEATURE_NOT_AVAIL, -16 .equiv E_PAYLOAD_SIZE, -17 .equiv E_PAYLOAD_W_FULL, -18 .equiv E_PAYLOAD_R_EMPTY, -19 .equiv E_CHANNEL, -20 .equiv E_MSBOF2TO5, -21 .equiv E_PIPE_NOT_AVAIL, -22 .equiv E_RETRY, -23 .equiv E_DELAY, -24 .equiv E_PAYLOAD_W_EMPTY, -25 .equiv E_DATA_RATE, -26 .equiv E_POWER, -27 .equiv E_RETRY_TX, -28 .equiv E_RETRY_MAX, -29 ;---------------------------------------------------- ;set register .macro WSET,name,value mov #name,w0 mov value,w1 call _write_wifi .endm ;---------------------------------------------------- ;get register .macro WGET,name mov #name,w0 call _read_wifi .endm ;---------------------------------------------------- .endif ;WIFILIB2 |
|
|
|
这是我的PIC16F88和NFR24.H文件FRIENFR24L01.H文件的主要文件。这3个文件是我的PIC16F88。这是ARDUNO文件。仍然不工作。问题是什么?我用ARDUINO的3.3V为我的两个nFr24L01+。你能查一下我的密码吗?谢谢。
以上来自于百度翻译 以下为原文 This is my main.c file for pic16F88 /* * Project: nRF Test TX * File: main.c * * Created on October 19, 2014, 3:14 PM * */ #include #include "newxc8_header.h" #include "stdint.h" /* Memory Map */ #define CONFIG 0x00 #define EN_AA 0x01 #define EN_RXADDR 0x02 #define SETUP_AW 0x03 #define SETUP_RETR 0x04 #define RF_CH 0x05 #define RF_SETUP 0x06 #define STATUS 0x07 #define OBSERVE_TX 0x08 #define CD 0x09 #define RX_ADDR_P0 0x0A #define RX_ADDR_P1 0x0B #define RX_ADDR_P2 0x0C #define RX_ADDR_P3 0x0D #define RX_ADDR_P4 0x0E #define RX_ADDR_P5 0x0F #define TX_ADDR 0x10 #define RX_PW_P0 0x11 #define RX_PW_P1 0x12 #define RX_PW_P2 0x13 #define RX_PW_P3 0x14 #define RX_PW_P4 0x15 #define RX_PW_P5 0x16 #define FIFO_STATUS 0x17 #define DYNPD 0x1C /* Bit Mnemonics */ /* configuratio nregister */ #define MASK_RX_DR 6 #define MASK_TX_DS 5 #define MASK_MAX_RT 4 #define EN_CRC 3 #define CRCO 2 #define PWR_UP 1 #define PRIM_RX 0 /* enable auto acknowledgment */ #define ENAA_P5 5 #define ENAA_P4 4 #define ENAA_P3 3 #define ENAA_P2 2 #define ENAA_P1 1 #define ENAA_P0 0 /* enable rx addresses */ #define ERX_P5 5 #define ERX_P4 4 #define ERX_P3 3 #define ERX_P2 2 #define ERX_P1 1 #define ERX_P0 0 /* setup of address width */ #define AW 0 /* 2 bits */ /* setup of auto re-transmission */ #define ARD 4 /* 4 bits */ #define ARC 0 /* 4 bits */ /* RF setup register */ #define PLL_LOCK 4 #define RF_DR_HIGH 3 #define RF_PWR 1 /* 2 bits */ /* general status register */ #define RX_DR 6 #define TX_DS 5 #define MAX_RT 4 #define RX_P_NO 1 /* 3 bits */ #define TX_FULL 0 /* transmit observe register */ #define PLOS_CNT 4 /* 4 bits */ #define ARC_CNT 0 /* 4 bits */ /* fifo status */ #define TX_REUSE 6 #define FIFO_FULL 5 #define TX_EMPTY 4 #define RX_FULL 1 #define RX_EMPTY 0 /* dynamic length */ #define DPL_P0 0 #define DPL_P1 1 #define DPL_P2 2 #define DPL_P3 3 #define DPL_P4 4 #define DPL_P5 5 /* Instruction Mnemonics */ #define R_REGISTER 0x00 /* last 4 bits will indicate reg. address */ #define W_REGISTER 0x20 /* last 4 bits will indicate reg. address */ #define REGISTER_MASK 0x1F #define R_RX_PAYLOAD 0x61 #define W_TX_PAYLOAD 0xA0 #define FLUSH_TX 0xE1 #define FLUSH_RX 0xE2 #define REUSE_TX_PL 0xE3 #define ACTIVATE 0x50 #define R_RX_PL_WID 0x60 #define NOP1 0xFF /// hardware spi pin defined #define LED_PIN RA1 // led test #define CS_Pin RB0 //set port as output #define CE_Pin RB4 //set port as output #define SCK_Pin RB1 //set port as output #define Mosi_Pin RB2 //set port as output #define Miso_Pin RB3 //set port as input #define HIGH 1 #define LOW 0 //#ifndef NRF24 #define NRF24 uint8_t PTX; uint8_t payload; uint8_t channel; uint8_t nrf24_rxFifoEmpty(); uint8_t nrf24_getStatus(); #define nrf24_ADDR_LEN 5 #define nrf24_CONFIG ((1< #define NRF24_MESSAGE_LOST 1 void LED_Blink(int fc){ int i; for(i=0;i __delay_ms(100); LED_PIN = 1; __delay_ms(100); } } void nrf24_ce_digitalwrite(uint8_t state){ if (state) { CE_Pin = 1; } else { CE_Pin = 0; } } void nrf24_csn_digitalwrite(uint8_t state){ if (state) { CS_Pin = 1; } else { CS_Pin = 0; } } void nrf24_sck_digitalwrite(uint8_t state){ if (state) { SCK_Pin = 1; } else { SCK_Pin = 0; } } void nrf24_mosi_digitalwrite( uint8_t state){ if (state) { Mosi_Pin = 1; } else { Mosi_Pin = 0; } } uint8_t nrf24_miso_digitalread(){ return 1; } //Clocks only one byte uint8_to the given nrf24 register */ /* software spi routine */ uint8_t spi_transfer(uint8_t tx){ uint8_t i = 0; uint8_t rs = 0; nrf24_sck_digitalwrite(LOW); for(i=0;i<8;i++) { if(tx & 0x80) // m***it first spi standard { nrf24_mosi_digitalwrite(HIGH); } else { nrf24_mosi_digitalwrite(LOW); } nrf24_sck_digitalwrite(HIGH); tx = tx << 1; if(Miso_Pin == 1) { rs |= 0x01; } nrf24_sck_digitalwrite(LOW); } return rs; } void nrf24_configRegister(uint8_t reg, uint8_t value){ nrf24_csn_digitalwrite(LOW); spi_transfer(W_REGISTER | (REGISTER_MASK & reg)); spi_transfer(value); nrf24_csn_digitalwrite(HIGH); } /* send and receive multiple bytes over SPI */ // checked with mirf void nrf24_transferSync(uint8_t *dataout,uint8_t *datain,uint8_t len){ uint8_t i; for(i=0;i } } //send multiple bytes over SPI // checked with mirf void nrf24_transmitSync(uint8_t *dataout,uint8_t len){ uint8_t i; for(i=0;i } } // init the hardware pins void nrf24_init(){ ANSEL = 0; TRISB = 0b00001000; TRISA = 0b00000000; // CMCON |= 7; OSCCON = 0x7C; nrf24_ce_digitalwrite(LOW); nrf24_csn_digitalwrite(HIGH); } // checked with mirf void nrf24_powerUpRx(){ PTX = 0; nrf24_csn_digitalwrite(LOW); nrf24_configRegister(CONFIG,nrf24_CONFIG|((1< nrf24_configRegister(STATUS,(1< // checked with mirf void nrf24_flushRx() { nrf24_csn_digitalwrite(LOW); spi_transfer(FLUSH_RX); nrf24_csn_digitalwrite(HIGH); } // Sets the important registers in the MiRF module and powers the module // in receiving mode // NB: channel and payload must be set now. // check with mirf void nrf24_config(){ // Set RF channel nrf24_configRegister(RF_CH,channel); // Set length of incoming payload nrf24_configRegister(RX_PW_P0, payload); nrf24_configRegister(RX_PW_P1, payload); // start receiver nrf24_flushRx(); nrf24_powerUpRx();// Start listening } /* Read single register from nrf24 */ //checked with mirf void nrf24_readRegister(uint8_t reg,uint8_t *value,uint8_t len) { nrf24_csn_digitalwrite(LOW); spi_transfer(R_REGISTER | (REGISTER_MASK & reg)); nrf24_transferSync(value,value,len); nrf24_csn_digitalwrite(HIGH); } /* Write to a single register of nrf24 */ void nrf24_writeRegister(uint8_t reg,uint8_t *value,uint8_t len){ // Writes an array of bytes into inte the MiRF registers. nrf24_csn_digitalwrite(LOW); spi_transfer(W_REGISTER | (REGISTER_MASK & reg)); nrf24_transmitSync(value,len); nrf24_csn_digitalwrite(HIGH); } // checked with mirf void nrf24_powerUpTx(){ PTX = 1; nrf24_configRegister(CONFIG,nrf24_CONFIG|((1< // check with mirf void nrf24_powerDown(){ nrf24_ce_digitalwrite(LOW); nrf24_configRegister(CONFIG,nrf24_CONFIG); } /* Set the RX address */ // check with mirf void nrf24_rx_address(uint8_t* adr){ nrf24_ce_digitalwrite(LOW); nrf24_writeRegister(RX_ADDR_P1,adr,nrf24_ADDR_LEN); nrf24_ce_digitalwrite(HIGH); } /* Set the TX address */ // check with mirf void nrf24_tx_address(uint8_t* adr){ /* RX_ADDR_P0 must be set to the sending addr for auto ack to work. */ nrf24_writeRegister(RX_ADDR_P0,adr,nrf24_ADDR_LEN); nrf24_writeRegister(TX_ADDR,adr,nrf24_ADDR_LEN); } /* Checks if data is available for reading */ /* Returns 1 if data is ready ... */ // check with mirf uint8_t nrf24_dataReady(){ // checks if data is available for reading // See note in getData() function - just checking RX_DR isn't good enough uint8_t status = nrf24_getStatus(); // We can short circuit on RX_DR, but if it's not set, we still need // to check the FIFO for any pending packets if ( status & (1 << RX_DR) ) return 1; return !nrf24_rxFifoEmpty();; } /* Checks if receive FIFO is empty or not */ // check with mirf uint8_t nrf24_rxFifoEmpty(){ uint8_t fifoStatus; nrf24_readRegister(FIFO_STATUS,&fifoStatus,sizeof(fifoStatus)); return (fifoStatus & (1 << RX_EMPTY)); } /* Reads payload bytes uint8_to data array */ // check with mirf void nrf24_getData(uint8_t *data1){ /* Pull down chip select */ nrf24_csn_digitalwrite(LOW); /* Send cmd to read rx payload */ spi_transfer(R_RX_PAYLOAD); /* Read payload */ nrf24_transferSync(data1,data1,payload); /* Pull up chip select */ nrf24_csn_digitalwrite(HIGH); /* Reset status register */ nrf24_configRegister(STATUS,(1< // Sends a data package to the default address. Be sure to send the correct // amount of bytes as configured as payload on the receiver. // check with mirf void nrf24_send(uint8_t* value){ uint8_t status; status = nrf24_getStatus(); while (PTX) { status = nrf24_getStatus(); if((status & ((1 << TX_DS) | (1 << MAX_RT)))){ PTX = 0; break; } } // Wait until last paket is send /* Go to Standby-I first */ nrf24_ce_digitalwrite(LOW); /* Set to transmitter mode , Power up if needed */ nrf24_powerUpTx(); nrf24_csn_digitalwrite(LOW); spi_transfer(FLUSH_TX); nrf24_csn_digitalwrite(HIGH); /* Pull down chip select */ nrf24_csn_digitalwrite(LOW); /* Write cmd to write payload */ spi_transfer(W_TX_PAYLOAD); /* Write payload */ nrf24_transmitSync(value,payload); /* Pull up chip select */ nrf24_csn_digitalwrite(HIGH); /* Start the transmission */ nrf24_ce_digitalwrite(HIGH); } /** * isSending. * * Test if chip is still sending. * When sending has finished return chip to listening. * */ // CHECK with mirf uint8_t nrf24_isSending(){ uint8_t status; if(PTX){ /* read the current status */ status = nrf24_getStatus(); /* if sending successful (TX_DS) or max retries exceded (MAX_RT). */ if((status & ((1 << TX_DS) | (1 << MAX_RT)))) { nrf24_powerUpRx(); return 0; /* false */ } return 1; /* true */ } return 0; /* false */ } // checked with mirf uint8_t nrf24_getStatus(){ uint8_t rv; nrf24_readRegister(STATUS,&rv,1); return rv; } //before main initilization uint8_t temp; uint8_t q = 0; uint8_t data_array[4]; uint8_t tx_address[5] = {0xE7,0xE7,0xE7,0xE7,0xE7}; // on receiver this should be rx_address uint8_t rx_address[5] = {0xE8,0xE8,0xF0,0xFC,0xD1}; // on receiver this should be tx_address uint8_t temp1,temp2; void main() { /* init hardware pins */ nrf24_init(); LED_Blink(5); //1 __delay_ms(2000); // Channel #2 , payload length: 4 nrf24_config(2,4); LED_Blink(3); //2 __delay_ms(2000); // Set the device addresses nrf24_tx_address(tx_address); nrf24_rx_address(rx_address); while(1) { LED_Blink(4); //3 __delay_ms(2000); //LED_PIN = HIGH; /* Fill the data buffer */ data_array[0] = 111; data_array[1] = 0X00; data_array[2] = 0x00; data_array[3] = 0X00; LED_Blink(5); //4 __delay_ms(2000); /* Automatically goes to TX mode */ nrf24_send(data_array); LED_Blink(5); //5 __delay_ms(10); /* Wait for transmission to end */ while(nrf24_isSending()); LED_Blink(10); // __delay_ms(2); /* Optionally, go back to RX mode ... */ nrf24_powerUpRx(); /* Or you might want to power down after TX */ // nrf24_powerDown(); /* Wait a little ... */ //__delay_ms(10); //LED_PIN = LOW; LED_Blink(10); __delay_ms(500); } } and nrf24.h file #ifndef NRF24 #define NRF24 #include "nRF24L01.h" #include #define LOW 0 #define HIGH 1 #define nrf24_ADDR_LEN 5 #define nrf24_CONFIG ((1< #define NRF24_TRANSMISSON_OK 0 #define NRF24_MESSAGE_LOST 1 /* adjustment functions */ void nrf24_init(); void nrf24_rx_address(uint8_t* adr); void nrf24_tx_address(uint8_t* adr); void nrf24_config(uint8_t channel, uint8_t pay_length); /* state check functions */ uint8_t nrf24_dataReady(); uint8_t nrf24_isSending(); uint8_t nrf24_getStatus(); uint8_t nrf24_rxFifoEmpty(); /* core TX / RX functions */ void nrf24_send(uint8_t* value); void nrf24_getData(uint8_t* data); /* use in dynamic length mode */ uint8_t nrf24_payloadLength(); /* post transmission analysis */ uint8_t nrf24_lastMessageStatus(); uint8_t nrf24_retransmissionCount(); /* Returns the payload length */ uint8_t nrf24_payload_length(); /* power management */ void nrf24_powerUpRx(); void nrf24_powerUpTx(); void nrf24_powerDown(); /* low level interface ... */ uint8_t spi_transfer(uint8_t tx); void nrf24_transmitSync(uint8_t* dataout,uint8_t len); void nrf24_transferSync(uint8_t* dataout,uint8_t* datain,uint8_t len); void nrf24_configRegister(uint8_t reg, uint8_t value); void nrf24_readRegister(uint8_t reg, uint8_t* value, uint8_t len); void nrf24_writeRegister(uint8_t reg, uint8_t* value, uint8_t len); /* -------------------------------------------------------------------------- */ /* You should implement the platform spesific functions in your code */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* In this function you should do the following things: * - Set MISO pin input * - Set MOSI pin output * - Set SCK pin output * - Set CSN pin output * - Set CE pin output */ /* -------------------------------------------------------------------------- */ extern void nrf24_setupPins(); /* -------------------------------------------------------------------------- */ /* nrf24 CE pin control function * - state:1 => Pin HIGH * - state:0 => Pin LOW */ /* -------------------------------------------------------------------------- */ extern void nrf24_ce_digitalWrite(uint8_t state); /* -------------------------------------------------------------------------- */ /* nrf24 CE pin control function * - state:1 => Pin HIGH * - state:0 => Pin LOW */ /* -------------------------------------------------------------------------- */ extern void nrf24_csn_digitalWrite(uint8_t state); /* -------------------------------------------------------------------------- */ /* nrf24 SCK pin control function * - state:1 => Pin HIGH * - state:0 => Pin LOW */ /* -------------------------------------------------------------------------- */ extern void nrf24_sck_digitalWrite(uint8_t state); /* -------------------------------------------------------------------------- */ /* nrf24 MOSI pin control function * - state:1 => Pin HIGH * - state:0 => Pin LOW */ /* -------------------------------------------------------------------------- */ extern void nrf24_mosi_digitalWrite(uint8_t state); /* -------------------------------------------------------------------------- */ /* nrf24 MISO pin read function /* - returns: Non-zero if the pin is high */ /* -------------------------------------------------------------------------- */ extern uint8_t nrf24_miso_digitalRead(); #endif nrf24l01.h file /* Memory Map */ #define CONFIG 0x00 #define EN_AA 0x01 #define EN_RXADDR 0x02 #define SETUP_AW 0x03 #define SETUP_RETR 0x04 #define RF_CH 0x05 #define RF_SETUP 0x06 #define STATUS 0x07 #define OBSERVE_TX 0x08 #define CD 0x09 #define RX_ADDR_P0 0x0A #define RX_ADDR_P1 0x0B #define RX_ADDR_P2 0x0C #define RX_ADDR_P3 0x0D #define RX_ADDR_P4 0x0E #define RX_ADDR_P5 0x0F #define TX_ADDR 0x10 #define RX_PW_P0 0x11 #define RX_PW_P1 0x12 #define RX_PW_P2 0x13 #define RX_PW_P3 0x14 #define RX_PW_P4 0x15 #define RX_PW_P5 0x16 #define FIFO_STATUS 0x17 #define DYNPD 0x1C /* Bit Mnemonics */ /* configuratio nregister */ #define MASK_RX_DR 6 #define MASK_TX_DS 5 #define MASK_MAX_RT 4 #define EN_CRC 3 #define CRCO 2 #define PWR_UP 1 #define PRIM_RX 0 /* enable auto acknowledgment */ #define ENAA_P5 5 #define ENAA_P4 4 #define ENAA_P3 3 #define ENAA_P2 2 #define ENAA_P1 1 #define ENAA_P0 0 /* enable rx addresses */ #define ERX_P5 5 #define ERX_P4 4 #define ERX_P3 3 #define ERX_P2 2 #define ERX_P1 1 #define ERX_P0 0 /* setup of address width */ #define AW 0 /* 2 bits */ /* setup of auto re-transmission */ #define ARD 4 /* 4 bits */ #define ARC 0 /* 4 bits */ /* RF setup register */ #define PLL_LOCK 4 #define RF_DR 3 #define RF_PWR 1 /* 2 bits */ /* general status register */ #define RX_DR 6 #define TX_DS 5 #define MAX_RT 4 #define RX_P_NO 1 /* 3 bits */ #define TX_FULL 0 /* transmit observe register */ #define PLOS_CNT 4 /* 4 bits */ #define ARC_CNT 0 /* 4 bits */ /* fifo status */ #define TX_REUSE 6 #define FIFO_FULL 5 #define TX_EMPTY 4 #define RX_FULL 1 #define RX_EMPTY 0 /* dynamic length */ #define DPL_P0 0 #define DPL_P1 1 #define DPL_P2 2 #define DPL_P3 3 #define DPL_P4 4 #define DPL_P5 5 /* Instruction Mnemonics */ #define R_REGISTER 0x00 /* last 4 bits will indicate reg. address */ #define W_REGISTER 0x20 /* last 4 bits will indicate reg. address */ #define REGISTER_MASK 0x1F #define R_RX_PAYLOAD 0x61 #define W_TX_PAYLOAD 0xA0 #define FLUSH_TX 0xE1 #define FLUSH_RX 0xE2 #define REUSE_TX_PL 0xE3 #define ACTIVATE 0x50 #define R_RX_PL_WID 0x60 #define NOP 0xFF These 3 files are for my PIC16F88. And this is the Arduino file. /********************************************************************* ** Device: nRF24L01+ ** ** File: EF_nRF24L01_TX.c ** ** ** ** ** ** Copyright (C) 2011 ElecFraks. ** ** This example code is in the public domain. ** ** ** ** Description: ** ** This file is a sample code for your reference. ** ** It's the v1.1 nRF24L01+ by arduino ** ** Created by ElecFreaks. Robi.W,24 July 2011 ** ** ** ** http://www.elecfreaks.com ** ** ** ** SPI-compatible ** ** CS - to digital pin 8 ** ** CSN - to digital pin 9 (SS pin) ** ** SCK - to digital pin 10 (SCK pin) ** ** MOSI - to digital pin 11 (MOSI pin) ** ** MISO - to digital pin 12 (MISO pin) ** ** IRQ - to digital pin 13 (MISO pin) ** *********************************************************************/ #include "NRF24L01.h" //*************************************************** #define TX_ADR_WIDTH 5 // 5 unsigned chars TX(RX) address width #define TX_PLOAD_WIDTH 4 // 32 unsigned chars TX payload unsigned char TX_ADDRESS[TX_ADR_WIDTH] = { 0xE7,0xE7,0xE7,0xE7,0xE7 }; // Define a static TX address unsigned char rx_buf[TX_PLOAD_WIDTH]; unsigned char tx_buf[TX_PLOAD_WIDTH]; //*************************************************** void setup() { pinMode(CE, OUTPUT); pinMode(SCK, OUTPUT); pinMode(CSN, OUTPUT); pinMode(MOSI, OUTPUT); pinMode(MISO, INPUT); pinMode(IRQ, INPUT); // attachInterrupt(1, _ISR, LOW); // interrupt enable Serial.begin(9600); init_io(); // Initialize IO port unsigned char status=SPI_Read(STATUS); Serial.print("status = "); Serial.println(status,HEX); // There is read the mode’s status register, the default value should be ‘E’ Serial.println("*****************RX_Mode start******************************R"); RX_Mode(); // set RX mode } void loop() { for(;;) { unsigned char status = SPI_Read(STATUS); // read register STATUS's value if(status&RX_DR) // if receive data ready (TX_DS) interrupt { SPI_Read_Buf(RD_RX_PLOAD, rx_buf, TX_PLOAD_WIDTH); // read playload to rx_buf SPI_RW_Reg(FLUSH_RX,0); // clear RX_FIFO for(int i=0; i<32; i++) { Serial.print(" "); Serial.print(rx_buf,HEX); // print rx_buf } Serial.println(" "); } SPI_RW_Reg(WRITE_REG+STATUS,status); // clear RX_DR or TX_DS or MAX_RT interrupt flag delay(1000); } } //************************************************** // Function: init_io(); // Description: // flash led one time,chip enable(ready to TX or RX Mode), // Spi disable,Spi clock line init high //************************************************** void init_io(void) { digitalWrite(IRQ, 0); digitalWrite(CE, 0); // chip enable digitalWrite(CSN, 1); // Spi disable } /************************************************** * Function: SPI_RW(); * * Description: * Writes one unsigned char to nRF24L01, and return the unsigned char read * from nRF24L01 during write, according to SPI protocol **************************************************/ unsigned char SPI_RW(unsigned char Byte) { unsigned char i; for(i=0;i<8;i++) // output 8-bit { if(Byte&0x80) { digitalWrite(MOSI, 1); // output 'unsigned char', MSB to MOSI } else { digitalWrite(MOSI, 0); } digitalWrite(SCK, 1); // Set SCK high.. Byte <<= 1; // shift next bit into MSB.. if(digitalRead(MISO) == 1) { Byte |= 1; // capture current MISO bit } digitalWrite(SCK, 0); // ..then set SCK low again } return(Byte); // return read unsigned char } /**************************************************/ /************************************************** * Function: SPI_RW_Reg(); * * Description: * Writes value 'value' to register 'reg' /**************************************************/ unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value) { unsigned char status; digitalWrite(CSN, 0); // CSN low, init SPI transaction status = SPI_RW(reg); // select register SPI_RW(value); // ..and write value to it.. digitalWrite(CSN, 1); // CSN high again return(status); // return nRF24L01 status unsigned char } /**************************************************/ /************************************************** * Function: SPI_Read(); * * Description: * Read one unsigned char from nRF24L01 register, 'reg' /**************************************************/ unsigned char SPI_Read(unsigned char reg) { unsigned char reg_val; digitalWrite(CSN, 0); // CSN low, initialize SPI communication... SPI_RW(reg); // Select register to read from.. reg_val = SPI_RW(0); // ..then read register value digitalWrite(CSN, 1); // CSN high, terminate SPI communication return(reg_val); // return register value } /**************************************************/ /************************************************** * Function: SPI_Read_Buf(); * * Description: * Reads 'unsigned chars' #of unsigned chars from register 'reg' * Typically used to read RX payload, Rx/Tx address /**************************************************/ unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes) { unsigned char status,i; digitalWrite(CSN, 0); // Set CSN low, init SPI tranaction status = SPI_RW(reg); // Select register to write to and read status unsigned char for(i=0;i pBuf = SPI_RW(0); // Perform SPI_RW to read unsigned char from nRF24L01 } digitalWrite(CSN, 1); // Set CSN high again return(status); // return nRF24L01 status unsigned char } /**************************************************/ /************************************************** * Function: SPI_Write_Buf(); * * Description: * Writes contents of buffer '*pBuf' to nRF24L01 * Typically used to write TX payload, Rx/Tx address /**************************************************/ unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes) { unsigned char status,i; digitalWrite(CSN, 0); // Set CSN low, init SPI tranaction status = SPI_RW(reg); // Select register to write to and read status unsigned char for(i=0;i SPI_RW(*pBuf++); } digitalWrite(CSN, 1); // Set CSN high again return(status); // return nRF24L01 status unsigned char } /**************************************************/ /************************************************** * Function: RX_Mode(); * * Description: * This function initializes one nRF24L01 device to * RX Mode, set RX address, writes RX payload width, * select RF channel, datarate & LNA HCURR. * After init, CE is toggled high, which means that * this device is now ready to receive a datapacket. /**************************************************/ void RX_Mode(void) { digitalWrite(CE, 0); SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // Use the same address on the RX device as the TX device SPI_RW_Reg(WRITE_REG + EN_AA, 0x01); // Enable Auto.Ack:Pipe0 SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); // Enable Pipe0 SPI_RW_Reg(WRITE_REG + RF_CH, 2); // Select RF channel 40 SPI_RW_Reg(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH); // Select same RX payload width as TX Payload width SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f); // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:RX. RX_DR enabled.. digitalWrite(CE, 1); // Set CE pin high to enable RX device // This device is now ready to receive one packet of 16 unsigned chars payload from a TX device sending to address // '3443101001', with auto acknowledgment, retransmit count of 10, RF channel 40 and datarate = 2Mbps. } /**************************************************/ Still does not works. What is the problem ? I'm using the arduino's 3.3V for my two nrf24l01+. Can you check my codes please. Thank you. |
|
|
|
SPI工作吗?你能从NRF芯片上读取寄存器吗?在设置通道之前,我要确保检测到芯片。你写代码或复制了吗?
以上来自于百度翻译 以下为原文 Does SPI work? Can you read registers from the nrf chip? This is what I do to make sure the chip is detected before setting channel ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;device available wget RF_CH inc w0,[SP++] wset RF_CH,w0 wget RF_CH cp w0,[--SP] bra nz,error_device ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Did you write your code or copy? |
|
|
|
我发现这个代码16F图片和改变频道,Adress等使它与阿杜伊诺一样。
以上来自于百度翻译 以下为原文 I found this code for 16F pics and changed channel,adress etc. Made it same with Arduino. |
|
|
|
SPI工作吗?你能从NRF芯片上读取寄存器吗?
以上来自于百度翻译 以下为原文 Does SPI work? Can you read registers from the nrf chip? |
|
|
|
我怎样检查呢?正如我说的,我是新来的,并试图学习:/给我这个代码的那个人说“这是软件SPI”。现在,我试图了解NFR24+PDF,因为你说,并检查代码。
以上来自于百度翻译 以下为原文 How can I check it ? As I said I'm new here and trying to learn :/ The guy who gave me this code said "this uses software SPI". Now I'm trying to understand nrf24+ pdf as you said and checking the codes. |
|
|
|
这是Cinzia在帖子#6和#10(bit bang)中提到的。使用软件在选择的管脚上生成SPI信号,而不是使用SSP外围设备。
以上来自于百度翻译 以下为原文 Hi This is what Cinzia mentioned in posts #6 and #10 (bit bang). Using software to generate the SPI signals on choosen pins instead of using an SSP peripheral. Best regards Jorge |
|
|
|
当我尝试我的代码,LED不会做第六闪烁。我也想写一个SPI文件,我认为这是解决我的问题的方法。请给我一些例子代码好吗?我需要学习它。阿杜伊诺很简单,有太多的例子,你可以看看和学习一些东西,但是这个真的很难学。
以上来自于百度翻译 以下为原文 When I try my codes , LED doesn't do 6th blink. Also I want to write an SPI file I think this is the solution for my problem. Can you give me some example codes please? I need to learn it. Arduino was easy there are too many examples, you can look and learn somethings but this one is really hard to learn. and thank you |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 04:05 , Processed in 1.505561 second(s), Total 114, Slave 97 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号