Commit ce7fea23 authored by hark's avatar hark

emu working with lcd on port c

parent 376dd9e6
......@@ -37,8 +37,8 @@
#include </usr/local/include/simavr/avr/avr_mcu_section.h>
AVR_MCU(F_CPU, "atmega328");
//AVR_MCU(F_CPU, "atmega48");
//AVR_MCU(F_CPU, "atmega328");
AVR_MCU(F_CPU, "atmega48");
static uint8_t subsecct = 0;
static uint8_t hour = 0;
......@@ -91,8 +91,15 @@ int main()
hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
hd44780_wait_ready(0);
EICRA = (1 << ISC00);
EIMSK = (1 << INT0);
// set up intterupt
// DDRD &= ~(1 << DDD2); // Clear the PD2 pin
// PD2 (PCINT0 pin) is now an input
// PORTD |= (1 << PORTD2); // turn On the Pull-up
// PD2 is now an input with pull-up enabled
EICRA = (1 << ISC00); /// set INT0 to trigger on ANY logic change
EIMSK = (1 << INT0); //// Turns on INT0
sei();
......
......@@ -13,15 +13,32 @@
/* HD44780 LCD port connections */
/*
// RW, connected to ground on our thingie, busy bbit?
#define HD44780_RW B, 2
// enable
#define HD44780_E B, 1
// rs
#define HD44780_RS B, 0
/* The data bits have to be not only in ascending order but also consecutive. */
// The data bits have to be not only in ascending order but also consecutive.
#define HD44780_D4 D, 4
// Whether to read the busy flag, or fall back to
// worst-time delays.
#define USE_BUSY_BIT 0
*/
/* HD44780 LCD port connections */
#define HD44780_RW B, 6
#define HD44780_E B, 5
#define HD44780_RS B, 4
/* The data bits have to be not only in ascending order but also consecutive. */
//#define HD44780_D4 D, 4
#define HD44780_D4 C, 0
/* Whether to read the busy flag, or fall back to
worst-time delays. */
#define USE_BUSY_BIT 1
#define USE_BUSY_BIT 0
......@@ -169,8 +169,8 @@ main(
/* Connect Data Lines to Port B, 0-3 D, 4 -7*/
/* These are bidirectional too */
for (int i = 4; i < 7; i++) {
avr_irq_t * iavr = avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('D'), i);
for (int i = 0; i < 4; i++) {
avr_irq_t * iavr = avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), i);
avr_irq_t * ilcd = hd44780.irq + IRQ_HD44780_D4 + i;
// AVR -> LCD
avr_connect_irq(iavr, ilcd);
......@@ -178,28 +178,33 @@ main(
avr_connect_irq(ilcd, iavr);
}
avr_connect_irq(
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 0),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 4),
hd44780.irq + IRQ_HD44780_RS);
avr_connect_irq(
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 1),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 5),
hd44780.irq + IRQ_HD44780_E);
avr_connect_irq(
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 2),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 6),
hd44780.irq + IRQ_HD44780_RW);
#define VCDBLA
#ifdef VCDBLA
avr_vcd_init(avr, "gtkwave_output.vcd", &vcd_file, 10 /* usec */);
avr_vcd_add_signal(&vcd_file,
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('D'), IOPORT_IRQ_PIN_ALL),
4 /* bits */, "D4-D7");
8 /* bits */, "D0-D7");
avr_vcd_add_signal(&vcd_file,
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 0),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), IOPORT_IRQ_PIN_ALL),
8 /* bits */, "C0-C7");
avr_vcd_add_signal(&vcd_file,
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 4),
1 /* bits */, "RS");
avr_vcd_add_signal(&vcd_file,
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 1),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 5),
1 /* bits */, "E");
avr_vcd_add_signal(&vcd_file,
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 2),
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 6),
1 /* bits */, "RW");
avr_vcd_add_signal(&vcd_file,
hd44780.irq + IRQ_HD44780_BUSY,
......@@ -224,10 +229,11 @@ main(
" Press 'r' to start recording a 'wave' file - with a LOT of data\n"
" Press 's' to stop recording\n"
);
#ifdef GDB
avr->gdb_port = 1234;
avr->state = cpu_Stopped;
avr_gdb_init(avr);
#endif
/*
* OpenGL init, can be ignored
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment