LPC845_BRK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC845_BRK

452 Views
Mr_Damian
Contributor I

Good afternoon everyone,

I was wondering if someone can help with with my query. I have started to work on the development board LPC845-BRK and I'm trying to setup the ADC and check the values obtained by the ADC. 

1) So my question is, is it possible to display the values to the console ? 

I did setup the console, but I get no output; it's strange as the: 

"BOARD_InitDebugConsole();"

is included.

 

2) Is it possible to find the specific register where the ADC value is stored ? 

 

The Code:

 

## Board Settings

* ------------------------

* Connect pins of ADC channel and LDR as below:

* LPC845 CONNECTS TO LDR Resistor-divider ckt

* Pin Name Board Location Pin Name

* ADC_8 PIO0_18 resistor divider o/p

* VCC CN1-40 LDR

* GND CN1-20 4.4k resistor

*

*/

 

/*******************************************************************************

* Standard C Included Files

******************************************************************************/

#include "fsl_device_registers.h"

#include "fsl_debug_console.h"

#include "board.h"

#include "fsl_adc.h"

#include "fsl_clock.h"

#include "fsl_power.h"

#include "pin_mux.h"

#include <stdbool.h>

 

/*******************************************************************************

* Definitions

******************************************************************************/

#define DEMO_ADC_BASE BOARD_INITPINS_ADC_8_LDR_PERIPHERAL

#define DEMO_ADC_SAMPLE_CHANNEL_NUMBER BOARD_INITPINS_ADC_8_LDR_CHANNEL

#define DEMO_ADC_CLOCK_SOURCE kCLOCK_Fro

 

/*******************************************************************************

* Prototypes

******************************************************************************/

static void ADC_Configuration(void);

 

/*******************************************************************************

* Variables

******************************************************************************/

adc_result_info_t adcResultInfoStruct;

 

/*******************************************************************************

* Main function

******************************************************************************/

int main(void)

{

/* Initialize board hardware. */

BOARD_InitPins();

BOARD_BootClockRUN();

BOARD_InitDebugConsole();

 

/* Configure the converter and work mode. */

ADC_Configuration();

//PRINTF("adcResult");

 

while(1)

{

/* Trigger the sequence's conversion by software */

ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE);

 

/* Wait for the converter to be done. */

while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_NUMBER, &adcResultInfoStruct))

{

}

 

/* Display the conversion result */

PRINTF("adcResult = %d\r\n", adcResultInfoStruct.result);

PRINTF("adcResult = \r\n");

}

}

 

/*******************************************************************************

* ADC Configuration function

******************************************************************************/

static void ADC_Configuration(void)

{

adc_config_t adcConfigStruct;

adc_conv_seq_config_t adcConvSeqConfigStruct;

 

#if !(defined(FSL_FEATURE_ADC_HAS_NO_CALIB_FUNC) && FSL_FEATURE_ADC_HAS_NO_CALIB_FUNC)

#if defined(FSL_FEATURE_ADC_HAS_CALIB_REG) && FSL_FEATURE_ADC_HAS_CALIB_REG

/* Calibration after power up. */

if (ADC_DoSelfCalibration(DEMO_ADC_BASE))

#else

uint32_t frequency;

#if defined(SYSCON_ADCCLKDIV_DIV_MASK)

frequency = CLOCK_GetFreq(DEMO_ADC_CLOCK_SOURCE) / CLOCK_GetClkDivider(kCLOCK_DivAdcClk);

#else

frequency = CLOCK_GetFreq(DEMO_ADC_CLOCK_SOURCE);

#endif /* SYSCON_ADCCLKDIV_DIV_MASK */

/* Calibration after power up. */

if (ADC_DoSelfCalibration(DEMO_ADC_BASE, frequency))

#endif /* FSL_FEATURE_ADC_HAS_CALIB_REG */

{

PRINTF("ADC_DoSelfCalibration() Done.\r\n");

}

else

{

PRINTF("ADC_DoSelfCalibration() Failed.\r\n");

}

#endif /* FSL_FEATURE_ADC_HAS_NO_CALIB_FUNC */

 

 

/* Configure the converter. */

#if defined(FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE) & FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE

adcConfigStruct.clockMode = kADC_ClockSynchronousMode; /* Using sync clock source. */

#endif /* FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE */

adcConfigStruct.clockDividerNumber = 1; /* The divider for sync clock is 2. */

#if defined(FSL_FEATURE_ADC_HAS_CTRL_RESOL) & FSL_FEATURE_ADC_HAS_CTRL_RESOL

adcConfigStruct.resolution = kADC_Resolution12bit;

#endif /* FSL_FEATURE_ADC_HAS_CTRL_RESOL */

#if defined(FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL) & FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL

adcConfigStruct.enableBypassCalibration = false;

#endif /* FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL */

#if defined(FSL_FEATURE_ADC_HAS_CTRL_TSAMP) & FSL_FEATURE_ADC_HAS_CTRL_TSAMP

adcConfigStruct.sampleTimeNumber = 0U;

#endif /* FSL_FEATURE_ADC_HAS_CTRL_TSAMP */

#if defined(FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE) & FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE

adcConfigStruct.enableLowPowerMode = false;

#endif /* FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE */

#if defined(FSL_FEATURE_ADC_HAS_TRIM_REG) & FSL_FEATURE_ADC_HAS_TRIM_REG

adcConfigStruct.voltageRange = kADC_HighVoltageRange;

#endif /* FSL_FEATURE_ADC_HAS_TRIM_REG */

ADC_Init(DEMO_ADC_BASE, &adcConfigStruct);

 

#if !(defined(FSL_FEATURE_ADC_HAS_NO_INSEL) && FSL_FEATURE_ADC_HAS_NO_INSEL)

/* Use the temperature sensor input to channel 0. */

ADC_EnableTemperatureSensor(DEMO_ADC_BASE, true);

#endif /* FSL_FEATURE_ADC_HAS_NO_INSEL. */

 

/* Enable channel DEMO_ADC_SAMPLE_CHANNEL_NUMBER's conversion in Sequence A. */

adcConvSeqConfigStruct.channelMask =

(1U << DEMO_ADC_SAMPLE_CHANNEL_NUMBER); /* Includes channel DEMO_ADC_SAMPLE_CHANNEL_NUMBER. */

adcConvSeqConfigStruct.triggerMask = 0U;

adcConvSeqConfigStruct.triggerPolarity = kADC_TriggerPolarityPositiveEdge;

adcConvSeqConfigStruct.enableSingleStep = false;

adcConvSeqConfigStruct.enableSyncBypass = false;

adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence;

ADC_SetConvSeqAConfig(DEMO_ADC_BASE, &adcConvSeqConfigStruct);

ADC_EnableConvSeqA(DEMO_ADC_BASE, true); /* Enable the conversion sequence A. */

/* Clear the result register. */

ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE);

while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_NUMBER, &adcResultInfoStruct))

{

}

ADC_GetConvSeqAGlobalConversionResult(DEMO_ADC_BASE, &adcResultInfoStruct);

}

 

0 Kudos
Reply
3 Replies

379 Views
Mr_Damian
Contributor I

Consol_Debug.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi Alice,

The options is not available for me, I'm not sure why ? 

Best

Damian 

0 Kudos
Reply

331 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Mr_Damian 

Please checked your project.

Alice_Yang_0-1695016526435.png

 

BR

Alice

 

0 Kudos
Reply

398 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Mr_Damian 

Do you use MCUXpresso IDE? Maybe it print to UART port, change SDK debug Console to "Semihost console" as below:

 

Alice_Yang_0-1694681721262.png

 

BR

Alice

 

0 Kudos
Reply