I'm using a low-power PIC16LF1554 together with an nRF24l01+ 2.4GHz transceiver.
During power-up, the PIC will try to initialise the RF module before the supply has reached the required minimum and will fail unless I insert a delay. Something like this
void main()
{
// 4x PLL, 8MHz internal oscillator = 32MHz clock
OSCCON = 0xF0;
// wait for HFINTOSC to stabilise
while (OSCSTATbits.HFIOFR == 0);
while (OSCSTATbits.HFIOFS == 0);
// configure TRIS, APFCON etc.
// (removed for clarity)
// **** necessary delay ****
__delay_ms(500);
// initialise RF transceiver
NRF_Setup();
// main loop
while (1)
{
// ... whatever ...
}
}
I don't quite understand why this is so because the RF has a minimum requirement of 1.9V and, according to the datasheet, the PIC requires 2.5V for the HFINTOSC to stabilise, so I thought it should be ok. (The nRF24l01+ is on a separate breakout board, which has other supporting components so maybe that affects things).
So, while this works fine and obviously the delay has no impact on the end application, I still don't like the idea of having to code an arbitrary delay and my gut feeling would be to try something a bit more deterministic. The 500ms is probably overkill and I could empirically find something shorter, but that doesn't feel like a robust approach.
So, is there some easy way to measure what the VDD is as it ramps during power-up, either in code or with external components, in the absence of a known voltage reference? Or perhaps that's not the problem I'm seeing and the delay is necessary for another reason?
EDIT In case it's relevant, these are the CONFIG settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled. SWDTEN bit is ignored.)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled. SBOREN bit is ignored.)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), 1.9V trip point selected.)
#pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
NRF_Setup
function. I think I should scope it to see if I can determine what's happening. \$\endgroup\$