(c) 5 marks The code below was written as an interupt service routine for an analog...
(c) 5 marks The code below was written as an interupt service routine for an analog to digital conversion for the ATmega328. Its purpose is to read the conversion result, copy it to an internal stack and to start a new conversion. It does not work corectly as there are five mistakes. Make changes to the code to correct its behaviour Note: Apartial instruction set summary for the AVR MCUS is available at the end of the exam script AtoDService ; Y is our internal result stack pointer ; It has already been set up to the correct address r16 pop ; read 8 bits of result ldd r16, ADCH sts r16, Y+ cbi ADCSRA, ADIF cbi PRR, PRAD sbi ADCSRA, ADSC push r16 ret
(c) 5 marks The code below was written as an interupt service routine for an analog to digital conversion for the ATmega328. Its purpose is to read the conversion result, copy it to an internal stack and to start a new conversion. It does not work corectly as there are five mistakes. Make changes to the code to correct its behaviour Note: Apartial instruction set summary for the AVR MCUS is available at the end of the exam script AtoDService ; Y is our internal result stack pointer ; It has already been set up to the correct address r16 pop ; read 8 bits of result ldd r16, ADCH sts r16, Y+ cbi ADCSRA, ADIF cbi PRR, PRAD sbi ADCSRA, ADSC push r16 ret