- This topic has 0 replies, 1 voice, and was last updated 1 month, 2 weeks ago by
Logan Moon.
-
AuthorPosts
-
February 6, 2025 at 9:33 pm #16772
(This message was transferred over from our old forum)
Posted August 19, 2015
By Todd DeBoer
[hr]
On 05/21/2010 aschoonen asked, “I’m trying to read a value with the ADC using uEZ 1.04, but the UEZADCRequestSingle() always gives me 0.The code I have is:
Code:
#include “uEZADC.h”
static T_uezDevice adc;
static ADC_RequestSingle adcRequest;
static TUInt32 adcValue;void main()
{
UEZADCOpen(“ADC0″, &adc);adcRequest.iADCChannel = 5;
adcRequest.iBitSampleSize = 10;
adcRequest.iTrigger = ADC_TRIGGER_NOW;
adcRequest.iCapturedData = &adcValue;while(1)
{
UEZADCRequestSingle(adc, &adcRequest); // ADC value is stored in adcValue// some code to output adcValue to screen
}UEZADCClose(adc);
}
(To be honest: the code I have is much more, but the settings of the ADC in code above are the same.)This is running on the ARM7 touch screen development kit with a 10K potentiometer attached to GPIO99_AD0.5 and to 3.3V and ground.
Does anyone have any clue why adcValue is always 0?”
[hr]
(Follow up post)Answered:
My first guess would be that the pin for channel 5 is not configured for A/D (UEZADCOpen does not configure pins). If you are using one of the DK-TS-KITs, check file Platform/FDI/ARM_CARRIER/LPC2478_pinConfig.h and change Code:
/* —– Pin P1[31] —– */
#define PINCFG_P1_31 0 // GPIO Port 1.31
//#define PINCFG_P1_31 1 // USB_OVRCR2n
//#define PINCFG_P1_31 2 // SCK1
//#define PINCFG_P1_31 3 // AD0[5]
#define PINSET_P1_31 0
#define PINCLR_P1_31 0
#define PINDIR_P1_31 0 // Input
#define PINMODE_P1_31 3 // Pull Down into Code:/* —– Pin P1[31] —– */
//#define PINCFG_P1_31 0 // GPIO Port 1.31
//#define PINCFG_P1_31 1 // USB_OVRCR2n
//#define PINCFG_P1_31 2 // SCK1
#define PINCFG_P1_31 3 // AD0[5]
#define PINSET_P1_31 0
#define PINCLR_P1_31 0
#define PINDIR_P1_31 0 // Input
#define PINMODE_P1_31 3 // Pull Down if you have not already done so. -
AuthorPosts
- You must be logged in to reply to this topic.