EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   Changing I/O Pins (https://ecomodder.com/forum/showthread.php/changing-i-o-pins-23770.html)

slewfoot 10-23-2012 08:49 PM

Changing I/O Pins
 
I've got an Arduino UNO with a seeedstudio shield. I've been attempting to use the LCD that comes with the kit by changing the LCD pins to

D10 -DI/RS
D12 -ENABLE
13 (A0) - DB4
14 (A1) - DB5
15 (A2) - DB6
16 (A3) - DB7

This is the pinout of the shield, I'm plugging in the LCD to BUS2.

So far, I've been unable to get the LCD to work at all.

I changed the following code to this...

Code:

void LCD::tickleEnable() {
        // send a pulse to enable  PD5
        PORTD |= (1 << 10);
        delayMicroseconds2(1); // pause 1 ms according to datasheet
        PORTD &= ~(1 << 10);
        delayMicroseconds2(1); // pause 1 ms according to datasheet
}

void LCD::cmdWriteSet() { //set enable (PB2) low and DI(PB4) low
        PORTD &= ~(1 << 10);
        delayMicroseconds2(1); // pause 1 ms according to datasheet
        PORTD &= ~(1 << 12);
}

byte LCD::pushNibble(byte value) { //db7=A02, db6=A01, db5 = A00, db4  = PB5
        value & 128 ? PORTB |= (1 << 13) : PORTB &= ~(1 << 13);
        value <<= 1;
        value & 128 ? PORTB |= (1 << 14) : PORTB &= ~(1 << 14);
        value <<= 1;
        value & 128 ? PORTB |= (1 << 15) : PORTB &= ~(1 << 15);
        value <<= 1;
        value & 128 ? PORTD |= (1 << 16) : PORTD &= ~(1 << 16);
        value <<= 1;
        return value;
}

void LCD::LcdCommandWrite(byte value) {
        value = pushNibble(value);
        cmdWriteSet();
        tickleEnable();
        value = pushNibble(value);
        cmdWriteSet();
        tickleEnable();
        delay2(5);
}

void LCD::LcdDataWrite(byte value) {
        PORTD |= (1 << 12); //di on PB4
        value = pushNibble(value);
        tickleEnable();
        value = pushNibble(value);
        tickleEnable();
        delay2(5);
}

It seems I am still missing something.... Anyone have any ideas?

slewfoot 10-23-2012 11:36 PM

Doh! Found the pin problem with the previous code chunk, but still not working... ugh!



void LCD::tickleEnable() {
// send a pulse to enable PB4
PORTB |= (1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
PORTB &= ~(1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
}

void LCD::cmdWriteSet() { //set enable (PB4) low and DI(PB2) low
PORTB &= ~(1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
PORTB &= ~(1 << 2);
}

byte LCD::pushNibble(byte value) { //db7=PC2, db6=PC1, db5 = PC0, db4 = PB5
value & 128 ? PORTB |= (1 << 5) : PORTB &= ~(1 << 5);
value <<= 1;
value & 128 ? PORTC |= (1 << 0) : PORTC &= ~(1 << 0);
value <<= 1;
value & 128 ? PORTC |= (1 << 1) : PORTC &= ~(1 << 1);
value <<= 1;
value & 128 ? PORTC |= (1 << 2) : PORTC &= ~(1 << 2);
value <<= 1;
return value;
}

void LCD::LcdCommandWrite(byte value) {
value = pushNibble(value);
cmdWriteSet();
tickleEnable();
value = pushNibble(value);
cmdWriteSet();
tickleEnable();
delay2(5);
}

void LCD::LcdDataWrite(byte value) {
PORTB |= (1 << 4); //di on pb4
value = pushNibble(value);
tickleEnable();
value = pushNibble(value);
tickleEnable();
delay2(5);
}


All times are GMT -4. The time now is 02:08 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com