Commit 70974f1e authored by phtseng's avatar phtseng

Revise to do ADC_POWER_ON() before ADC_Open() for ADC StdDriver sample codes.

Change-Id: I604986cea4acc21e73a3e487692c9c8201b2da1c
parent 0c8acfcb
......@@ -151,13 +151,13 @@ void AdcContScanModeTest()
u8Option = getchar();
if(u8Option == '1')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as continuous scan, input mode as single-end and
enable the analog input channel 0, 1, 2 and 3 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_CONTINUOUS, 0xF);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......@@ -194,13 +194,13 @@ void AdcContScanModeTest()
}
else if(u8Option == '2')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as continuous scan, input mode as differential and
enable analog input channel 0 and 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_DIFFERENTIAL, ADC_ADCR_ADMD_CONTINUOUS, 0x5);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......
......@@ -170,14 +170,14 @@ uint32_t GetAVDDCodeByADC(void)
/* Lock protected registers */
SYS_LockReg();
/* Power on ADC */
ADC_POWER_ON(ADC);
/* Configure ADC: single-end input, single scan mode, enable ADC analog circuit. */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_SINGLE, BIT7);
/* Configure the analog input source of channel 7 as internal band-gap voltage */
ADC_CONFIG_CH7(ADC, ADC_ADCHER_PRESEL_INT_BANDGAP);
/* Power on ADC */
ADC_POWER_ON(ADC);
/* Clear conversion finish flag */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......
......@@ -113,12 +113,12 @@ void ADC_PWMTrigTest_SingleOpMode()
{
printf("\n<<< PWM trigger test (Single mode) >>>\n");
/* Set the ADC operation mode as single, input mode as single-end and enable the analog input channel 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_SINGLE, 0x1 << 2);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as single, input mode as single-end and enable the analog input channel 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_SINGLE, 0x1 << 2);
/* Configure the hardware trigger condition and enable hardware trigger; PWM trigger delay: (4*10) system clock cycles*/
ADC_EnableHWTrigger(ADC, ADC_ADCR_TRGS_PWM, 0);
......
......@@ -116,12 +116,12 @@ void AdcResultMonitorTest()
printf("+----------------------------------------------------------------------+\n");
printf("\nIn this test, software will compare the conversion result of channel 2.\n");
/* Set the ADC operation mode as continuous scan, input mode as single-end and enable the analog input channel 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_CONTINUOUS, 0x1 << 2);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as continuous scan, input mode as single-end and enable the analog input channel 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_CONTINUOUS, 0x1 << 2);
/* Enable ADC comparator 0. Compare condition: conversion result < 0x800; match Count=5. */
printf(" Set the compare condition of comparator 0: channel 2 is less than 0x800; match count is 5.\n");
ADC_ENABLE_CMP0(ADC, 2, ADC_ADCMPR_CMPCOND_LESS_THAN, 0x800, 5);
......
......@@ -119,14 +119,13 @@ void AdcSingleCycleScanModeTest()
u8Option = getchar();
if(u8Option == '1')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as single-cycle, input mode as single-end and
enable the analog input channel 0, 1, 2 and 3 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_SINGLE_CYCLE, 0xF);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......@@ -144,14 +143,13 @@ void AdcSingleCycleScanModeTest()
}
else if(u8Option == '2')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as single-cycle, input mode as differential and
enable analog input channel 0 and 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_DIFFERENTIAL, ADC_ADCR_ADMD_SINGLE_CYCLE, 0x5);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......
......@@ -125,13 +125,12 @@ void AdcSingleModeTest()
u8Option = getchar();
if(u8Option == '1')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as single, input mode as single-end and enable the analog input channel 2 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_SINGLE_END, ADC_ADCR_ADMD_SINGLE, 0x1 << 2);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......@@ -156,14 +155,13 @@ void AdcSingleModeTest()
}
else if(u8Option == '2')
{
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Set the ADC operation mode as single, input mode as differential and
enable analog input channel 2 for differential input channel pair 1 */
ADC_Open(ADC, ADC_ADCR_DIFFEN_DIFFERENTIAL, ADC_ADCR_ADMD_SINGLE, 0x1 << 2);
/* Power on ADC module */
ADC_POWER_ON(ADC);
/* Clear the A/D interrupt flag for safe */
ADC_CLR_INT_FLAG(ADC, ADC_ADF_INT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment