Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD 4Bit - PCF8574

Status
Not open for further replies.

Suraj143

Active Member
Hi,
I'm stuck on a program. That I'm driving a 16X2 LCD from a PIC12F675 via a PCF8574 I2C module.
I'm confused on how to write the LCD Enable Line make transition from Low TO High state on each nibble in 4 bit mode?

Rich (BB code):
LCD_Send_CMD    movwf        Temp
            andlw        b'11110000'
            movwf        Data_U
            swapf        Temp,W
            andlw        b'11110000'
            movwf        Data_L
            ;
            call        I2C_Start
            ;
            movf        Slave_Address,W
                call         I2C_Out
                call         I2C_NAK
;                ;
                movf        Data_U,W
                iorlw        0x0C            ;enable=1 and rs =0
                call         I2C_Out
                call         I2C_NAK
                ;
                movf        Data_U,W
                iorlw        0x08            ;enable=0 and rs =0
                call         I2C_Out
                call         I2C_NAK
                ;
                movf        Data_L,W
                iorlw        0x0C            ;enable=1 and rs =0
                call         I2C_Out
                call         I2C_NAK
                ;
                movf        Data_L,W
                iorlw        0x08            ;enable=0 and rs =0
                call         I2C_Out
                call         I2C_NAK
                ;
                call        I2C_Stop
                return
 
If you are sensing only I2c commands from your pic (and only writing code for the PIC, you should be able to just send 8-bit ASCII values to the PCF8574 I2C via standard I2C. The PCF code in the PCF8574 should translate the values you send to the Hitachi chip with parallel interface to the 16x2 display.

In other words, you shouldn't have to worry about nibbles. But that's my guess. I haven't seen the datasheet for the PFC8574 I2C interface chip.
 
If you need to transfer the two nibbles separately, look up the AND command
ANDWL 0b00001111, 0
This will remove the leading digits in the value you just read from a register with S

You can then read the same value from the register, use the swapf
swapf registerNamw, 0
Then and with the literal used above (pb00001111) to get only the four LSBs

swap will swap the higher 4 bits with the lower four bits while keeping them in the same order (thst is, it does not replace bit 7 with bit 0, it replaces bit 7 with bit 3).
 
The PFC8574 bare chip is 8bit wide.But I'm using I2C LCD module.Which can be connected to a LCD using 4bit method.

In 4 bit mode I'm struggling how to achieve Enable pulse in two nibbles?

1698939456487.png


1698939342987.png
 
There are many examples of this on the net.

I2Cwrite( highdata & RS); // or not for cmd
I2Cwrite( highdata & RS & enableon);
I2Cwrite( highdata);
I2Cdelay();
I2Cwrite( lowdata & RS ); // or not for cmd
I2Cwrite( lowdata & RS & enableon);
I2Cwrite( lowdata );

That's how I do it.
 
There are many examples of this on the net.

I2Cwrite( highdata & RS); // or not for cmd
I2Cwrite( highdata & RS & enableon);
I2Cwrite( highdata);
I2Cdelay();
I2Cwrite( lowdata & RS ); // or not for cmd
I2Cwrite( lowdata & RS & enableon);
I2Cwrite( lowdata );

That's how I do it.
But that doesn't look like the TS's PIC assembly code.
 
I have done it in assembly, but that code will be at work.. I am on a sabbatical from work until Monday.

Asm is exactly the same procedure.
I don't think he is asking about the procedure - I think he is simply asking about bit manipulation in ASM to set the right bits to set the "other" nibble in the 8-bit byte that control the four non-value nibble . I'm walking to work now, I'll wait for the OP to confirm what he needs.
 
There are many examples of this on the net.

I2Cwrite( highdata & RS); // or not for cmd
I2Cwrite( highdata & RS & enableon);
I2Cwrite( highdata);
I2Cdelay();
I2Cwrite( lowdata & RS ); // or not for cmd
I2Cwrite( lowdata & RS & enableon);
I2Cwrite( lowdata );

That's how I do it.
Many thanks & you got what I mean.
Thats is how the arduino library does.Also I convert it to assembly code.

Worked nicely.

Thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top