Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need to fix this code AVR , need to implement that counter from 0 to F automatic - 7 Segment , which increases every 1

need to fix this code AVR , need to implement that counter from 0 to F automatic - 7 Segment , which increases every 1 second and, using external interruptions, create a START / PAUSE button (PC2) and another RESET button (PC3). Note: The RESET button can only work if the count is stopped.

The Counter part, increasing every second i had done, using external interruption too, the problem is on Start/pause button. The Reset has been done but without Pause dependancy..

#define F_CPU 16000000UL #include #include #include ISR(PCINT1_vect); volatile int c = 0; volatile int i = 16; volatile int flag = 0;

int main() { unsigned char vector_disp[16] = {0xE7, 0x84, 0xD3, 0xD6, 0xB4, 0x76, 0x77, 0xC4, 0xF7, 0xF6, 0xF5, 0x37, 0x63, 0x97, 0x73, 0x71}; DDRB = 0b00000011; PORTB = 0b00000001; DDRC = 0b00000000; PORTC = 0b00001100; DDRD = 0b11111111; PORTD = 0b00000000; PCICR = 0b00000011; PCMSK1 = 0b00001100; PCMSK0 = 0b00010100; sei(); while (1) { for (c = 0; c < i; c++) { PORTD = vector_disp[c]; _delay_ms(500); //500 due to simulation speed } } }

ISR(PCINT1_vect) { if (!(PINC & (1 << 2))) { flag = 1; if (flag == 1) { i = 0; } if (flag == 0) { i = 16; }

} else if (!(PINC & (1 << 3))) { c = -1; } }

Its Atmega328p

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions