/*
Dot Matrix Display Controller
Chip: ATMEGA128
Serial EEPROM: AT24C256
RTC: DS1307
Matrix Size: 16 Row x [n] Column
Character programmable via: PS-2 Keyboard & Serial DB-9 (using custom data downloader)
RTC format hh:mm:ss and DD:MM:YY
*/
#define F_CPU 14745600UL //11059200UL
// define of I/O Register Control Ports
#define RCLK PC0
#define SCLK PC1
#define SERIAL PC2
#define DATAPORT PORTC
#define DATADDR DDRC
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include "font16x16.h"
#include "font5x7.h"
#include "twi.h"
#include "ds1307.h"
#include "seeprom.h"
#include "animasi.h"
#include "ps2kbd.c"
#include "uart.h"
#include "menu.h"
volatile uint8_t baris, kolom, baris_aktif, modul_aktif;
volatile uint16_t geser, prescaler;
#define SCLK_LOW() {DATAPORT &= ~(1<<SCLK);}
#define SCLK_HIGH() {DATAPORT |= (1<<SCLK);}
#define SCLOCK() {SCLK_LOW();SCLK_HIGH();}
#define RCLK_LOW() {DATAPORT &= ~(1<<RCLK);}
#define RCLK_HIGH() {DATAPORT |= (1<<RCLK);}
#define RCLOCK() {RCLK_LOW();RCLK_HIGH();}
void reset_register() // MEMBERSIHKAN REGISTER
{
uint8_t kolom;
for(kolom = 0; kolom < (COL_PER_MODUL+16); kolom++)
{
buffer[kolom] = 0;
DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
}
ISR(TIMER3_COMPA_vect, ISR_NOBLOCK) // Periode interrupt 30ms, interrupt memakan waktu 21ms, sisa waktu 9ms
{
for(baris_aktif = 0; baris_aktif < 16; baris_aktif++)
{
for(baris = 0; baris < 16; baris++) // buat nyalakan
{
if(baris == baris_aktif) DATAPORT |= (1<<SERIAL); else DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
for(kolom = 0; kolom < COL_PER_MODUL; kolom++)
{
temp = buffer[kolom];
if(temp & (1<<baris_aktif)) DATAPORT |= (1<<SERIAL); else DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
_delay_us(330); // delay 350us
for(kolom = 0; kolom < (COL_PER_MODUL+16); kolom++) // buat matikan
{
DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
}
}
int main(void)
{
DATADDR |= (1<<SERIAL) | (1<<SCLK) | (1<<RCLK); // inisialisasi port-port
DATAPORT &= ~((1<<SERIAL) | (1<<SCLK) | (1<<RCLK));
JUMLAH_MODUL = eeprom_read_byte(&JUMLAH_MODULE); // jumlah modul
if(JUMLAH_MODUL > 160)
{
JUMLAH_MODUL = 1;
eeprom_write_byte(&JUMLAH_MODULE, JUMLAH_MODUL);
}
COL_PER_MODUL = eeprom_read_byte(&COL_PER_MODULE); // jumlah kolom per modul
if(COL_PER_MODUL > 160)
{
COL_PER_MODUL = 32;
eeprom_write_byte(&COL_PER_MODULE, COL_PER_MODUL);
}
lebar_display = JUMLAH_MODUL * COL_PER_MODUL;
slot = 0;
buffer_enable = 1;
program_kbd = 0;
reset_register();
twiInit(10);
UART_Init(MYUBRR); // inisialisasi komunikasi serial
kbd_init(); // inisialisasi keyboard
sei(); // enable global interrupt
delay(2000);
kbd_send(0xFF); // kirim perintah untuk me-reset keyboard
delay(1000); // tunggu bentar
key = kbd_get_scancode(); // baca balasan dari keyboard
if(key == 0xFA) // jika 0xFA maka ada keyboard
{
write_menu_flash(PSTR("PROG MODE"),1);
write_menu_flash(PSTR("F1=HELP"),2);
help_position = 0;
TIMER3_INIT(); // inisialisasi interupsi timer 2 untuk scanning display
program_kbd = 1;
while(program_kbd) do_menu(); // proses memprogram kalimat menggunakan keyboard
}
kbd_release();
TIMER0_INIT(); // inisialisasi interupsi timer 0 untuk timeout komunikasi serial
TIMER1_INIT(); // inisialisasi interupsi timer 1 untuk update jam dan tanggal
TIMER3_INIT(); // inisialisasi interupsi timer 2 untuk scanning display
slot = 0;
wdt_enable(WDTO_2S);
while(1)
{
MAX_SLOT = eeprom_read_byte(&MAX_SLOTE);
if(slot<MAX_SLOT)
{
kecepatan_masuk = SEEPROM_READ(((uint16_t) slot * 1024) + 2);
kecepatan_keluar = SEEPROM_READ(((uint16_t) slot * 1024) + 3);
transition_delay = ((uint16_t) SEEPROM_READ(((uint16_t) slot * 1024) + 4) << 8) + SEEPROM_READ(((uint16_t) slot * 1024) + 5);
if(transition_delay > 10000) transition_delay = 500;
copy_buffer(slot);
animasi_masuk(slot);
if(SEEPROM_READ((uint16_t) slot * 1024) != GESER_KIRI2) // kalo bukan geser kiri terooos, maka proses seperti biasa
{
wait(transition_delay);
animasi_keluar(slot);
}
slot++;
} else slot = 0;
}
return 0;
}
adiba said:this is main program
/*
Dot Matrix Display Controller
Chip: ATMEGA128
Serial EEPROM: AT24C256
RTC: DS1307
Matrix Size: 16 Row x [n] Column
Character programmable via: PS-2 Keyboard & Serial DB-9 (using custom data downloader)
RTC format hh:mm:ss and DD:MM:YY
*/
#define F_CPU 14745600UL //11059200UL
// define of I/O Register Control Ports
#define RCLK PC0
#define SCLK PC1
#define SERIAL PC2
#define DATAPORT PORTC
#define DATADDR DDRC
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include "font16x16.h"
#include "font5x7.h"
#include "twi.h"
#include "ds1307.h"
#include "seeprom.h"
#include "animasi.h"
#include "ps2kbd.c"
#include "uart.h"
#include "menu.h"
volatile uint8_t baris, kolom, baris_aktif, modul_aktif;
volatile uint16_t geser, prescaler;
#define SCLK_LOW() {DATAPORT &= ~(1<<SCLK);}
#define SCLK_HIGH() {DATAPORT |= (1<<SCLK);}
#define SCLOCK() {SCLK_LOW();SCLK_HIGH();}
#define RCLK_LOW() {DATAPORT &= ~(1<<RCLK);}
#define RCLK_HIGH() {DATAPORT |= (1<<RCLK);}
#define RCLOCK() {RCLK_LOW();RCLK_HIGH();}
void reset_register() // MEMBERSIHKAN REGISTER
{
uint8_t kolom;
for(kolom = 0; kolom < (COL_PER_MODUL+16); kolom++)
{
buffer[kolom] = 0;
DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
}
ISR(TIMER3_COMPA_vect, ISR_NOBLOCK) // Periode interrupt 30ms, interrupt memakan waktu 21ms, sisa waktu 9ms
{
for(baris_aktif = 0; baris_aktif < 16; baris_aktif++)
{
for(baris = 0; baris < 16; baris++) // buat nyalakan
{
if(baris == baris_aktif) DATAPORT |= (1<<SERIAL); else DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
for(kolom = 0; kolom < COL_PER_MODUL; kolom++)
{
temp = buffer[kolom];
if(temp & (1<<baris_aktif)) DATAPORT |= (1<<SERIAL); else DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
_delay_us(330); // delay 350us
for(kolom = 0; kolom < (COL_PER_MODUL+16); kolom++) // buat matikan
{
DATAPORT &= ~(1<<SERIAL);
SCLOCK();
}
RCLOCK();
}
}
int main(void)
{
DATADDR |= (1<<SERIAL) | (1<<SCLK) | (1<<RCLK); // inisialisasi port-port
DATAPORT &= ~((1<<SERIAL) | (1<<SCLK) | (1<<RCLK));
JUMLAH_MODUL = eeprom_read_byte(&JUMLAH_MODULE); // jumlah modul
if(JUMLAH_MODUL > 160)
{
JUMLAH_MODUL = 1;
eeprom_write_byte(&JUMLAH_MODULE, JUMLAH_MODUL);
}
COL_PER_MODUL = eeprom_read_byte(&COL_PER_MODULE); // jumlah kolom per modul
if(COL_PER_MODUL > 160)
{
COL_PER_MODUL = 32;
eeprom_write_byte(&COL_PER_MODULE, COL_PER_MODUL);
}
lebar_display = JUMLAH_MODUL * COL_PER_MODUL;
slot = 0;
buffer_enable = 1;
program_kbd = 0;
reset_register();
twiInit(10);
UART_Init(MYUBRR); // inisialisasi komunikasi serial
kbd_init(); // inisialisasi keyboard
sei(); // enable global interrupt
delay(2000);
kbd_send(0xFF); // kirim perintah untuk me-reset keyboard
delay(1000); // tunggu bentar
key = kbd_get_scancode(); // baca balasan dari keyboard
if(key == 0xFA) // jika 0xFA maka ada keyboard
{
write_menu_flash(PSTR("PROG MODE"),1);
write_menu_flash(PSTR("F1=HELP"),2);
help_position = 0;
TIMER3_INIT(); // inisialisasi interupsi timer 2 untuk scanning display
program_kbd = 1;
while(program_kbd) do_menu(); // proses memprogram kalimat menggunakan keyboard
}
kbd_release();
TIMER0_INIT(); // inisialisasi interupsi timer 0 untuk timeout komunikasi serial
TIMER1_INIT(); // inisialisasi interupsi timer 1 untuk update jam dan tanggal
TIMER3_INIT(); // inisialisasi interupsi timer 2 untuk scanning display
slot = 0;
wdt_enable(WDTO_2S);
while(1)
{
MAX_SLOT = eeprom_read_byte(&MAX_SLOTE);
if(slot<MAX_SLOT)
{
kecepatan_masuk = SEEPROM_READ(((uint16_t) slot * 1024) + 2);
kecepatan_keluar = SEEPROM_READ(((uint16_t) slot * 1024) + 3);
transition_delay = ((uint16_t) SEEPROM_READ(((uint16_t) slot * 1024) + 4) << 8) + SEEPROM_READ(((uint16_t) slot * 1024) + 5);
if(transition_delay > 10000) transition_delay = 500;
copy_buffer(slot);
animasi_masuk(slot);
if(SEEPROM_READ((uint16_t) slot * 1024) != GESER_KIRI2) // kalo bukan geser kiri terooos, maka proses seperti biasa
{
wait(transition_delay);
animasi_keluar(slot);
}
slot++;
} else slot = 0;
}
return 0;
}
yes..Mega 8 should work well. The said task can too be done with 89S52 or any PIC micros. Its all up to your knowledge.anemokid said:hello.. good day!
is it right to use MCU ATMEL ATMEGA8 in our project "electronic message board via sms"?... we are planning to use gsm module in our circuit...
this is main program
Code:/* }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?