- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By following the DE1_SoC_ADC example of the DE1 revF CD, I can collect measurements from a single ADC channel. I have connected a pulse rate sensor to the ADC and am using a timer interrupt on the NIOS II processor to take measurements from the ADC as 2ms interval. However, when I want to measure a different channel, I am unable to receive and data from it?
Any help would be appreciated.
int ch[2];
int main(){
printf("Pulse Rate Demo\r\n");
// register the timer irq to be serviced by handle_timer_interrupt() function
alt_irq_register(TIMER_IRQ, 0, handle_timer_interrupt);
// activate the time
IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE,
ALTERA_AVALON_TIMER_CONTROL_CONT_MSK
| ALTERA_AVALON_TIMER_CONTROL_START_MSK
| ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);
while(1){
ch[0] = IORD(SW_BASE, 0x00) & 0x07;
ch[1] = IORD(SW_BASE, 0x4) & 0x07;
// set measure number for ADC convert
IOWR(ADC_LTC2308_BASE, 0x01, nReadNum);
//printf("%d,%d,%d,%d, %d,%d\n",thresh,T,P,N,adcVal,BPM-1);
printf("ch:%d, i:%d, BPM:%d\n",ch[i],i,BPM);
usleep(200*1000);
}
}
void handle_timer_interrupt(void*p, alt_u32 param)
{
// clear irq status in order to prevent retriggering
IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0);
// your isr code here
i=!i;
if(i==1){
// start measure
IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x00);
IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x01);
IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x00);
i=0;
}
else {
IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x00);
IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x01);
IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x00);
}
// wait measure done
while ((IORD(ADC_LTC2308_BASE,0x00) & 0x01) == 0x00);
Value = IORD(ADC_LTC2308_BASE, 0x01);
adcVal = ((float)(Value/1000.0)/5)*1024;
.............................................
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I have the project file for reference

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page