Hello everybody. I'm currently working with a connected launchpad. I trying to program the ADC converter with a timer0 trigger, but I don't can activate the ADC interrupt. The code is posted here
//*****************************************************************************
// Variable del reloj de sistema
//*****************************************************************************
uint32_t g_ui32SysClock;
//*****************************************************************************
// Variables del programa
//*****************************************************************************
uint32_t g_ui32Flags = 0;
uint32_t adc_isr_count = 0;
uint32_t adc_result[2];
//*****************************************************************************
// Rutina de error
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
// Código de interrupción del conversor analógico
//*****************************************************************************
void
AdcIsr0(void){
// Borramos el flag de interrupción
ADCIntClear(ADC0_BASE, 0);
// Almacenamos en el vector adc_result el resultado de todas las conversiones
ADCSequenceDataGet(ADC0_BASE, 0, adc_result);
// Volteamos el pin PN0
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ui32Flags);
g_ui32Flags = !g_ui32Flags;
adc_isr_count++;
}
int
main(void)
{
// Configuramos la velocidad del ARM en 120MHz
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
// Habilitamos los perifércos que vamos a utilizar.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // Puerto N para los leds
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Puerto E para el canal analógico AN0
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // Timer0 para el disparo del timer
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // Conversor AD
//Configuramos como salida el puerto PN0
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
//Configuramos el timer 0.
// Valor de recarga para 6khz = 120MHz / 20000
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER0_BASE, TIMER_A, 20000); // 6khz
TimerControlTrigger(TIMER0_BASE, TIMER_A, true); // habilitamos el disparo del ADC mediante el timer0
//Habilitamos el timer0
TimerEnable(TIMER0_BASE, TIMER_A);
//Configuramos el conversor AD
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); //Configuramos el canal 0
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2); //Configuramos el canal 1
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1|ADC_CTL_IE|ADC_CTL_END);
IntEnable(INT_ADC0SS0);
ADCIntEnable(ADC0_BASE, ADC_INT_SS0);
IntMasterEnable();
ADCSequenceEnable(ADC0_BASE, 0);
//Bucle sin fin
while(1)
{
}
}
I seems that the code is right.... but not work
Thanks!