Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Provide code that implements an interrupt service routine every 20 milliseconds

ID: 3661416 • Letter: P

Question

Provide code that implements an interrupt service routine every 20 milliseconds using timer 1. You may assume that the microcontroller is using a 40MHz SYS_FREQ and that PB_DIV=2. Provide comments to explain what each line does. Your ISR need only clear the interrupt flag and set a variable called tick_flag that has already been declared and initialised to zero. Provide code that initialises the timer and interrupt systems. The ISR has a function prototype of type: void __ISR(_TIMER_1_VECTOR, ipl2) yourhandler(void); should be used to contain the code for your interrupt service routine. Provide code for an interrupt service routine and an initialisation routine that allows use of timer2 and timer 3 to provide a 5 second interrupt.

Explanation / Answer

Set the peripheral clock to 10MHz to make math simple... */ SYSTEMConf igPerf ormance (SYS_FREQ) ; mOSCSetPBDIV(OSC_PB_DIV_8) ; Start with basics, This is the PORTA, set up a digital pin to blink an LED. RA3 with the MAX32 LED 4 on it . V PORTSetPinsDigitalOut ( IOPORT_A, BIT_3 ) ; while (1) { // PIC32 has an instruction that toggles an I/O mPORTAToggleBits (BIT_3) ; for (n=0;n
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote