Forum Discussion
Altera_Forum
Honored Contributor
13 years agoIORD_ALTERA_AVALON_PIO_DATA execution speed
Is there a faster way to read a pin than using the IORD_ALTERA_AVALON_PIO_DATA macro? I'm finding the code below is running quite slow, but by removing the second condition (i.e. reducing the n...
Altera_Forum
Honored Contributor
13 years agoIn this particular case you could write it as
if ((IORD_ALTERA_AVALON_PIO_DATA(PIO_CONTROL_IN_BASE) & 0x02) != 0) {
sample_array = IORD_ALTERA_AVALON_PIO_DATA(PIO_ADC_DATA_BASE);
i++;
} In the more generaL case, avoid reading to the same HW-address multiple times and use a temporary variableuint32 temp = IORD_ALTERA_AVALON_PIO_DATA(PIO_CONTROL_IN_BASE) ;
if ((temp == 0x02) || (temp == 0x03)) {
sample_array = IORD_ALTERA_AVALON_PIO_DATA(PIO_ADC_DATA_BASE);
i++;
}