This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why NRF24LE1 ADC is reading value always as 255?

I am doing a register retention gzll transmit code with ADC. But problem is that the ADC value transmitted is always 255, if I connect ground to ADC it would read 247. Why is there such a problem here. Here is my code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include"reg24le1.h" // I/O header file for NRF24LE1
//#include"hal_uart.h" // library containing serial communication functions
#include"hal_delay.h" // header file containing delay functions
#include"hal_clk.h"
#include <stdio.h>
#include "nrf24le1.h"
#include "gzll_mcu.h"
#include "gzll.h"
#include "hal_adc.h"
// Repeated putchar to print a string
/*void putstring(char *s)
{
while(*s != 0)
hal_uart_putchar(*s++);
}*/
int gzlinit=0,val=0;
uint8_t payload[3];
void wakeup_irq() interrupt INTERRUPT_WUOPIRQ
{
;//putstring("Hello Ranjan I woke up\n");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Dear Support Engineer, I am waiting for your reply.

  • Have you set the HAL_ADC_INP_AIN6 pin as input? 

    Best regards,
    Kenneth

  • Does this code of line  hal_adc_set_input_channel(HAL_ADC_INP_AIN6); not do that?  So how do we set a pin as input? (Also at the same time let me know how to set it as output? Say P0DIR =0 and P01 = 0 set it as output?). Since the pin wake up on port 0 needs P0DIR = 0x02, on the same lines P0DIR=0x22 will set AIN6 also as input?

  • Even after declaring P0DIR as 0x22, I am still getting the same problem. ADC reads 255 and if I ground it instead of reading 0 it reads 247.

  • I recommend to try the SDK example: \nRFgo SDK 2.3.0.10040\source_code\projects\nrfgo_sdk\adc_examples\adc_single_step_mode 

    You should only need to modify: hal_adc_set_input_channel(HAL_ADC_INP_AIN0); 

1 2