From c71fc39f4847fbce6d8decb57bd7c3a5c00b2fec Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Thu, 22 Apr 2021 00:36:54 +0200 Subject: [PATCH] VFD debugging --- display/firmware/main.c | 54 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/display/firmware/main.c b/display/firmware/main.c index b35e891..f36acc6 100644 --- a/display/firmware/main.c +++ b/display/firmware/main.c @@ -98,6 +98,10 @@ static void init() { // initialize VFD display_init(); + // clear + display_write(0x01, 0, 0); + // display on, no cursor + display_write(0x0c, 0, 0); // Initialize CAN interface can_init(BITRATE_125_KBPS); @@ -171,12 +175,52 @@ static void loop() { } static void test() { - // clear - display_write(0x01, 0, 0); - // display on, no cursor - display_write(0x0c, 0, 0); + static uint8_t test_char = 0; display_write(0x80, (const uint8_t *) "Hello, world", 12); - _delay_ms(1000); + display_write(0xc0, (const uint8_t *) &test_char, 1); + test_char++; + _delay_ms(100); +} + +static void test2() { + // PC5, PC6, PC7: output (VFD RS, RW, E), RS=0, RW=1, E=1 + // PD0, PD1, PB0, PB1, PB7, PD5, PD6, PD7: output (VFD DB) - can be switched to input (pullup not needed) + PORTC &= ~(_BV(PC5) | _BV(PC6) | _BV(PC7)); + PORTB &= ~(_BV(PB0) | _BV(PB1) | _BV(PB7)); + PORTD &= ~(_BV(PD0) | _BV(PD1) | _BV(PD5) | _BV(PD6) | _BV(PD7)); + PORTC |= _BV(PC5); + _delay_us(10); + PORTC &= ~_BV(PC5); + PORTC |= _BV(PC6); + _delay_us(10); + PORTC &= ~_BV(PC6); + PORTC |= _BV(PC7); + _delay_us(10); + PORTC &= ~_BV(PC7); + PORTD |= _BV(PD0); + _delay_us(10); + PORTD &= ~_BV(PD0); + PORTD |= _BV(PD1); + _delay_us(10); + PORTD &= ~_BV(PD1); + PORTB |= _BV(PB0); + _delay_us(10); + PORTB &= ~_BV(PB0); + PORTB |= _BV(PB1); + _delay_us(10); + PORTB &= ~_BV(PB1); + PORTB |= _BV(PB7); + _delay_us(10); + PORTB &= ~_BV(PB7); + PORTD |= _BV(PD5); + _delay_us(10); + PORTD &= ~_BV(PD5); + PORTD |= _BV(PD6); + _delay_us(10); + PORTD &= ~_BV(PD6); + PORTD |= _BV(PD7); + _delay_us(10); + PORTD &= ~_BV(PD7); } int main() {