/** * Input change notification interrupt, triggered by the * Hall sensor. Used to determine what the motor speed * is, so we are able to display the image properly. */ void __ISR(_CHANGE_NOTICE_VECTOR, ipl7) ChangeNotice_Handler(void) { /* Time variables used to count clock ticks */ uint32_t period = 0; uint32_t dummy; uint8_t hall; /* First thing, read the port, so no further * interrupts will be generated! */ hall = HALL; /* Clear interrupt flag */ IFS1bits.CNIF = 0; /* We only want rising-edge interrupts, so ignore * all others */ if (hall != 0) return; /* Calculate how much has passed since last interrupt */ period = readCounter(); /* Count again for the next interrupt */ startCounter(); /* We must configure a timer to trigger at every column of pixels */ dummy = period / IMAGE_WIDTH; initTimer(dummy); /* Reset the column index for the LEDs */ column = START_POINT; // defined as 0 }