Hello,
I started using this forum and it’s really helping me!
But I still have a problem.
I am using the C8051F320 microcontroller to configure the nRF24L01 module via SPI.
I send the configuration commands to the RF module and the data. I can see them on the MOSI pin and also the answer on the MISO pin but the RF module is not sending these data via RF! (I check if the VDD_PA pin on the RF module is going high).
Here is my code for TX mode:
void TX_Mode(void)
{
CE = 0;
SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADDR_WIDTH); // Writes TX_Address to nRF24L01
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADDR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack
SPI_Write_reg(WRITE_REG + EN_AA, 0x00); // Disable Auto.Ack:Pipe0
SPI_Write_reg(WRITE_REG + EN_RXADDR, 0x01); // Enable Pipe0
SPI_Write_reg(WRITE_REG + SETUP_RETR, 0x00); // Setup retry off
SPI_Write_reg(WRITE_REG + RF_CH, 2); // Select RF channel 2
SPI_Write_reg(WRITE_REG + RF_SETUP, 0x0F); // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR
SPI_Write_reg(WRITE_REG + CONFIG, 0x38); // PTX enabled, enable CRC(1 byte), interrupt RXDR enabled, power down mode
}
//--------------------------------------------------------------------
// Main Routine
//--------------------------------------------------------------------
void main(void)
{
MCU_Init();
Port_Init();
ADC_Init();
Init_T0();
Init_T2();
Start_T2();
SPI_Init();
Int_Init();
TX_Mode();
while (TRUE)
{
}
}
/**********************************************************************
* General interrupts definitions
**********************************************************************///*****************************************
// Timer0 Overflow interrupt
//
// Used for CE pulse signal
// Timeout:12µs
//*****************************************
void T0_Overflow(void) interrupt T0_INTERRUPT
{
EA = 0; // disable global interrupt during processing
CE = 0; // Clear CE pulse after 20 us
TR0 = 0;
EA = 1; // enable global interrupt again
Led3 = ~Led3;
}
//*****************************************
// Timer2 Overflow interrupt
//
// Used to read ADC value every 30 ms
//*****************************************
void T2_Overflow(void) interrupt T2_INTERRUPT
{
// EA = 0;
TF2H = 0; // Clear interrupt flag
Led2 = ~Led2;
// EA = 1; // enable global interrupt again
}
//******************************************
// ADC end of conversion interrupt
//
// When ADC finish conversion than ADC
// interrupt flag is cleared
//*****************************************
void ADC_EndConversion(void)interrupt INTERRUPT_ADC0_EOC
{
EA = 0;
Led1 = ~Led1;
TX_PAYLOAD[0] = ADC0L; // Write first byte (ADC low) into the SPI buffer
TX_PAYLOAD[1] = ADC0H; // Write second byte (ADC high) into the SPI buffer
SPI_Write_reg(WRITE_REG + STATUS, 0x7E); // Write register status, clear previous interrupts
SPI_Write_reg(WRITE_REG + CONFIG, 0x3A); // Power up TX mode
Flush_TX(); // Flush TX FIFO
SPI_Write_Buf(WR_TX_PLOAD, TX_PAYLOAD, 0x02); // Writes data to TX payload and send them to SPI MOSI
EA = 1;
CE = 1;
Start_T0();
ADC0CN = 0x82; // Clear ADC Interrupt flag and enable ADC again
}
Can anyone help me?
Is there any time issue or configuration issue?
Thanks!