Other Parts Discussed in Thread: TMS320F2812, CONTROLSUITE
Hello,
Add the moment I want to read out the TMS320F2812 ADC value. The program works when want to do it in continues run, but when I am triggering it whit the SOC_SEQ it just give a 0 zero as result. Could anybody point me in the right direction?
The code is in the attachment.
Kind regards,
Ralf
int main (void)
{
unsigned int Value;
/* Initialize the periphery */
BSP_Init();
/* Initialize a memory management system */
GEO_InitMem();
// Init ADC
// Specific clock setting for this example:
EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/ADC_MODCLK
EDIS;
InitAdc();
AdcRegs.ADCTRL3.bit.SMODE_SEL = 1; // Setup simultaneous sampling mode
AdcRegs.ADCMAXCONV.all = 0x000;
// Specific ADC setup for this example:
AdcRegs.ADCTRL3.bit.ADCCLKPS = 1; // ADC clock 0 = Fclk/1 1 = Fclk/2
AdcRegs.ADCTRL1.bit.CONT_RUN = 0; // Stops after each run
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x1; // Setup conv from ADCINA1 & ADCINB1
AdcRegs.ADCMAXCONV.all = 0;
// Start ADC
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
for(;;)
{
if(AdcRegs.ADCST.bit.INT_SEQ1 ==0)
{
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; // Start Sequence 1 ADC conversion.
}
if(AdcRegs.ADCST.bit.INT_SEQ1)
{
Value = (AdcRegs.ADCRESULT1>>4); // Uitleze nADC
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
}
}