用的STC8G1K08,20引脚的单片机加贴片型NRF24L01
sbit NRF_CSN = P5^4;
sbit NRF_IRQ = P1^7;
sbit NRF_CE = P1^6;
sbit NRF_SCK = P1^5;
sbit NRF_MISO = P1^4;
sbit NRF_MOSI = P1^3;
/********************************************/
/* 函数功能:检测24L01是否存在 */
/* 返回值; 0 存在 */
/* 1 不存在 */
/********************************************/
unsigned char NRF24L01_Check(void)
{
unsigned char check_in_buf[5]={0x11,0x22,0x33,0x44,0x55};
unsigned char check_out_buf[5]={0x00};
NRF24L01_Write_Buf(WRITE_REG+TX_ADDR, check_in_buf, 5);
NRF24L01_Read_Buf(READ_REG+TX_ADDR, check_out_buf, 5);
if((check_out_buf[0] == 0x11)&&\
(check_out_buf[1] == 0x22)&&\
(check_out_buf[2] == 0x33)&&\
(check_out_buf[3] == 0x44)&&\
(check_out_buf[4] == 0x55))return 0;
else return 1;
}
这个电路和程序都是网上下载的,在进入主程序while之前有这个检测程序,检测nrf24l01是否存在就过不了,一直是返回1
希望大佬帮忙看看
|