ATMega32 contains 32K bytes of internal Flash memory for program storage. The Flash is organized as 16K x 16 because all AVR instructions are 16 or 32 bits wide. For software security, the Flash Program memory space is divided into two sections, Boot Program section and Application Program section.
The Flash Memory has an endurance of at least 10,000 write/erase cycles. The ATMega32 Program Counter (PC) is 14-bit wide, thus addressing the 16K program memory locations.
ATMega32 has 2K bytes of internal SRAM. It's far smaller than its internal Flash. For any situation that the user needs to store a large amount of constant data, it is effective to store and read those data from internal Flash. For example we need to store font data at the amount of 1K bytes. This example project uses a lot of internal SRAM since the program store font and graphic data in SRAM instead of Flash.
The AVR LibC "pgmspace.h" contains routine that declare data into Flash Memory, reading byte data from Flash Memory, etc.
Program Simulation |
/* * Example_2.c * * Created: 7/19/2023 1:52:49 PM * Author : Admin */ #include <avr/io.h> #include <avr/pgmspace.h> #define F_CPU 8000000UL #include "util/delay.h" /*Declare constant data that will store in program Flash Memory*/ const char cCathode[] PROGMEM = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; const char cAnode[] PROGMEM = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E}; int main(void) { DDRC = 0xFF; while (1) { for (char i=0;i<16;i++) { /*Read Flash Data and assign to PORTC*/ PORTC = pgm_read_byte(&cCathode[i]); _delay_ms(500); } } }
Click here to download its zip file.
This comment has been removed by the author.
ReplyDeletedid you make the 100v voltmeter?
ReplyDeletesend me the link to see how you did it
great video!!
Oh, next time I will make a DVM to measure a higher voltage.
Delete