Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Kindly perform the following code in language C. It would be better if the code is typed rather than being handwritten. thanks in advance. Q2-
Kindly perform the following code in language C. It would be better if the code is typed rather than being handwritten. thanks in advance.
Q2- Answer the following questions (Total 10 Marks) Assume you want to program an ATmega328 MCU to print the number of times a user press and then release a pushbutton connected to an input pin using an External Interrupt. Complete the following code (Arduino Sketch): [10 Marks) //global variables here void setup() { //disable all interrupt cli(): Serial.begin(9600); pinMode(2, INPUT_PULLUP); EICRA EIMSK = sei(): ) //write value here //write value here //enable interrupts void loop() 2 //define ISR ISR(INTO_vect) Relevant ATmega328 registers: EICRA - External Interrupt Control Register A The external interrupt control register A contains control bits for interrupt sense control BH (Ox60) Read/Write Initial Value 6 0 EICRA 3 ISC11 RW 0 2 ISC10 R/W 0 1 ISC01 R/W 0 R R 0 ISCOO RAW 0 D ISC01 ISCOO Description 0 0 The low level of INTO generates an interrupt request. 0 1 Any logical change on INTO generates an interrupt request 1 0 The falling edge af INTO generates an interrupt request 1 1 The rising edge of INTO generates an interrupt request EIMSK-ExternalInterrupt Mask Register But 6 5 4 3 2 0x1D(0:30) INT1 Read/Write R R R R R RW Initial Value D 0 0 0 0 2 EIMSK R INTO RW 0 0 0 Q2- Answer the following questions (Total 10 Marks) Assume you want to program an ATmega328 MCU to print the number of times a user press and then release a pushbutton connected to an input pin using an External Interrupt. Complete the following code (Arduino Sketch): [10 Marks) //global variables here void setup() { //disable all interrupt cli(): Serial.begin(9600); pinMode(2, INPUT_PULLUP); EICRA EIMSK = sei(): ) //write value here //write value here //enable interrupts void loop() 2 //define ISR ISR(INTO_vect) Relevant ATmega328 registers: EICRA - External Interrupt Control Register A The external interrupt control register A contains control bits for interrupt sense control BH (Ox60) Read/Write Initial Value 6 0 EICRA 3 ISC11 RW 0 2 ISC10 R/W 0 1 ISC01 R/W 0 R R 0 ISCOO RAW 0 D ISC01 ISCOO Description 0 0 The low level of INTO generates an interrupt request. 0 1 Any logical change on INTO generates an interrupt request 1 0 The falling edge af INTO generates an interrupt request 1 1 The rising edge of INTO generates an interrupt request EIMSK-ExternalInterrupt Mask Register But 6 5 4 3 2 0x1D(0:30) INT1 Read/Write R R R R R RW Initial Value D 0 0 0 0 2 EIMSK R INTO RW 0 0 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started