Content originally posted in LPCWare by Analog2Can on Mon May 05 11:30:45 MST 2014 Hi,
I want to see the output of the ADC from my LPC11C24 on my console. I'm using the adc example (nxp_lpcxpresso_11c24_periph_adc). I already defined DEBUG_ENABLE and DEBUG_SEMIHOSTING but I don't get anything on my Console. This is what the example code look like.
#include "board.h"
#include <stdio.h>
#if !defined(CHIP_LPC1125)
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
static ADC_CLOCK_SETUP_T ADCSetup;
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
/*****************************************************************************
* Private functions
****************************************************************************/
static void Init_ADC_PinMux(void)
{
#if (defined(BOARD_NXP_XPRESSO_11U14) || defined(BOARD_NGX_BLUEBOARD_11U24))
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 11, FUNC2);
#elif defined(BOARD_NXP_XPRESSO_11C24)
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_11, FUNC2);
#else
#error "Pin muxing for ADC not configured"
#endif
}
/*****************************************************************************
* Public functions
****************************************************************************/
/**
* @briefmain routine for ADC example
* @returnFunction should not exit
*/
int main(void)
{
uint16_t dataADC;
int j;
SystemCoreClockUpdate();
Board_Init();
Init_ADC_PinMux();
DEBUGSTR("ADC Demo\r\n");
/* ADC Init */
Chip_ADC_Init(LPC_ADC, &ADCSetup);
Chip_ADC_EnableChannel(LPC_ADC, ADC_CH0, ENABLE);
while (1) {
/* Start A/D conversion */
Chip_ADC_SetStartMode(LPC_ADC, ADC_START_NOW, ADC_TRIGGERMODE_RISING);
/* Waiting for A/D conversion complete */
while (Chip_ADC_ReadStatus(LPC_ADC, ADC_CH0, ADC_DR_DONE_STAT) != SET) {}
/* Read ADC value */
Chip_ADC_ReadValue(LPC_ADC, ADC_CH0, &dataADC);
/* Print ADC value */
DEBUGOUT("ADC value is 0x%x\r\n", dataADC);
/* Delay */
j = 500000;
while (j--) {}
}
/* Should not run to here */
return 0;
}
#endif /* !defined(CHIP_LPC1125) */
Content originally posted in LPCWare by lpcxpresso-support on Tue May 06 01:42:39 MST 2014 Glad you got it working. For future reference, the LPCOpen FAQ on using the debugout functionality does mention the need to switch on semihosting in LPCXpresso: