This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

adc tms320c5505

Other Parts Discussed in Thread: TMS320C5505

dear,

i want to convert 50 Hz sine wave into digital by applying on chip 10bit adc in tms320c5505..following is my code adc with timer interrupt..my question is ..is this correct..do i need to convert the SARDATA value for the final output..

______________________________________________________

void Init_SAR(void)
{
*SARCTRL = 0x3C00; // Select AIN3, which is GPAIN1
*SARCLKCTRL = 0x0031; // 100/50 = 2MHz
*SARPINCTRL = 0x7104;
*SARGPOCTRL = 0;
return;
}

_______________________________________________


Uint16 Read_GPAIN1(void)
{
Uint16 val, i;

for(i=0;i<100; i++)
asm(" nop");

*SARCTRL = 0xB400;

while(1)
{
for(i=0;i<50; i++)
asm(" nop");
val = *SARDATA;
if((val&0x8000) == 0)
break;
}

return val;
}

_____________________________________________________

interrupt void gpt0Isr(void)
{
unsigned char TIAFR_VAL=0,i=0;
hitIsr = TRUE;
TIAFR_VAL = CSL_SYSCTRL_REGS->TIAFR;
IRQ_clear(TINT_EVENT);
//status = sar_test_Int_keypad_voltage();
if((TIAFR_VAL&0x01) == 0x01)
{
adc_out[i]=Read_GPAIN1();
i++;
}
IRQ_clear(TINT_EVENT);
/* Clear Timer Interrupt Aggregation Flag Register (TIAFR) */
CSL_SYSCTRL_REGS->TIAFR = 0x01;
}

_________________________________________________