Easyrider83
Advanced Member level 5
![Advanced Member level 5](/styles/images/ranks/hlevel2.gif)
- Joined
- Oct 11, 2011
- Messages
- 1,608
- Helped
- 374
- Reputation
- 748
- Reaction score
- 363
- Trophy points
- 1,363
- Location
- Tallinn, Estonia
- Activity points
- 8,575
Here I'll share my codes for this nordic wireless solution.
First of all I should warn that I'm not answering a stupid questions.
So, lets get start.
Some of my projects with NRF24L01 use.
Radio Key based on STM8S microcontroller, powered by CR2032 battery. Working range 1-10m depends of output power.
View attachment Schematic2_STM8.rar
Software example for previos project for IAR.
View attachment IAR_STM8S_RadioKey.rar
Initialization example with my code library:
This picture should explain how this library works. The NRF24L01.c and header file are common for all processors and architectures.
![NRF24L01_Layers.png NRF24L01_Layers.png](https://www.edaboard.com/data/attachments/27/27029-e32d5c6ba75fefc26e08dfa637ac17fd.jpg)
For example, GPIO library for Microchip controllers looks like this:
For STM8S:
For STM32 (shorted)
Support bitbang for faster response.
The same way we are using SPI peripheral (you'll find an examples inside attachments).
For Keil uVision I wrote an Wizard that perform all initiation procedures. Attaching them too:
View attachment NRF24L01_STM32_Keil.rar
And for bonus today I have finished the wizard configuration utility:
**broken link removed**
![NRF24L01_Wizard_Preview.png NRF24L01_Wizard_Preview.png](https://www.edaboard.com/data/attachments/27/27035-9c3808540aa9a8d57c708ca8995a5294.jpg)
And some example how to use NRF24L01 with ARM based STM32F100 for Keil uVision 4.
View attachment TEST_MODULEv2.rar
Hope I will have some time to support this topic.
First of all I should warn that I'm not answering a stupid questions.
So, lets get start.
Some of my projects with NRF24L01 use.
Radio Key based on STM8S microcontroller, powered by CR2032 battery. Working range 1-10m depends of output power.
View attachment Schematic2_STM8.rar
Software example for previos project for IAR.
View attachment IAR_STM8S_RadioKey.rar
Initialization example with my code library:
Code:
unsigned char Init_NRF24L01 (void)
{
/*24L01 INIT*/
RF_InitTypeDef RF_InitStruct;
RF_InitStruct.RF_Power_State=RF_Power_On;
RF_InitStruct.RF_Config=RF_Config_IRQ_RX_Off|RF_Config_IRQ_TX_On|RF_Confing_IRQ_Max_Rt_On;
RF_InitStruct.RF_CRC_Mode=RF_CRC16_On;
RF_InitStruct.RF_Mode=RF_Mode_TX;
RF_InitStruct.RF_Pipe_Auto_Ack=RF_Pipe0_Ack_Enable;
RF_InitStruct.RF_Enable_Pipe=RF_Pipe0_Enable;
RF_InitStruct.RF_Setup=RF_Setup_5_Byte_Adress;
RF_InitStruct.RF_TX_Power=RF_TX_Power_High;
RF_InitStruct.RF_Data_Rate=RF_Data_Rate_1Mbs;
RF_InitStruct.RF_Channel=0x35;
RF_InitStruct.RF_RX_Adress_Pipe0[0]='B';
RF_InitStruct.RF_RX_Adress_Pipe0[1]='A';
RF_InitStruct.RF_RX_Adress_Pipe0[2]='T';
RF_InitStruct.RF_RX_Adress_Pipe0[3]='O';
RF_InitStruct.RF_RX_Adress_Pipe0[4]='N';
RF_InitStruct.RF_TX_Adress[0]='B';
RF_InitStruct.RF_TX_Adress[1]='A';
RF_InitStruct.RF_TX_Adress[2]='T';
RF_InitStruct.RF_TX_Adress[3]='O';
RF_InitStruct.RF_TX_Adress[4]='N';
RF_InitStruct.RF_Payload_Size_Pipe0=16;
RF_InitStruct.RF_Auto_Retransmit_Count=1;
RF_InitStruct.RF_Auto_Retransmit_Delay=1;
return RF_Init(&RF_InitStruct);
}
![NRF24L01_Layers.png NRF24L01_Layers.png](https://www.edaboard.com/data/attachments/27/27029-e32d5c6ba75fefc26e08dfa637ac17fd.jpg)
For example, GPIO library for Microchip controllers looks like this:
Code:
void PIN_ON (char * port, char pin)
{
*port|=(1<<pin);
}
void PIN_OFF (char * port, char pin)
{
*port&=~(1<<pin);
}
Code:
void PIN_ON(GPIO_TypeDef * GPIOx,u8 PINx)
{
GPIOx->ODR=GPIOx->IDR|PINx;
}
void PIN_OFF(GPIO_TypeDef * GPIOx,u8 PINx)
{
GPIOx->ODR=GPIOx->IDR&(~(PINx));
}
u8 PIN_SYG(GPIO_TypeDef * GPIOx, u8 PINx)
{
return GPIOx->IDR&PINx;
}
void PIN_IN (GPIO_TypeDef * GPIOx,u8 PINx)
{
GPIOx->DDR&=(~PINx);
}
void PIN_OUT_PP (GPIO_TypeDef * GPIOx,u8 PINx)
{
GPIOx->DDR|=PINx;
}
void PIN_INV(GPIO_TypeDef * GPIOx, u8 PINx)
{
GPIOx->ODR=GPIOx->IDR^PINx;
}
Code:
void PIN_ON(GPIO_TypeDef * GPIOx,u16 PINx)
{
#ifdef STM32_BitBang
GPIOx->BSRR=PINx;
#else
GPIOx->ODR=GPIOx->IDR|(PINx);
#endif
}
The same way we are using SPI peripheral (you'll find an examples inside attachments).
For Keil uVision I wrote an Wizard that perform all initiation procedures. Attaching them too:
View attachment NRF24L01_STM32_Keil.rar
And for bonus today I have finished the wizard configuration utility:
**broken link removed**
![NRF24L01_Wizard_Preview.png NRF24L01_Wizard_Preview.png](https://www.edaboard.com/data/attachments/27/27035-9c3808540aa9a8d57c708ca8995a5294.jpg)
And some example how to use NRF24L01 with ARM based STM32F100 for Keil uVision 4.
View attachment TEST_MODULEv2.rar
Hope I will have some time to support this topic.
Attachments
Last edited: