cancel
Showing results for 
Search instead for 
Did you mean: 

LCD_8bits

aymen
Associate II
Posted on December 12, 2012 at 10:09

I am trying to use an LCD HD44780 (2X40) with STM3210C-eval. I want to configure it for 8 bits mode.

#re-inventing-the-wheel
33 REPLIES 33
Posted on December 12, 2012 at 13:22

I am trying to use an LCD HD44780 (2X40) with STM3210C-eval. I want to configure it for 8 bits mode.

Ok, but aren't there like thousands of example drivers on the internets already?

As a minimal post here consider:

A link to a datasheet on your specific panel.

A schematic or wiring diagram for your specific configuration.

A link or attachment of the current code.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
aymen
Associate II
Posted on December 13, 2012 at 10:49

I can write data on the LCD with 4bits mode (LCD_4bits from keil), I want to change the mode to 8bits. I need the pins assignements.

this is the configuration for 4bits_mode:

/* PINS:

   - DB4 = PC3

   - DB5 = PC2

   - DB6 = PC1

   - DB7 = PC0

   - E   = PC10

   - RW  = PC11

   - RS  = PC12                                                               */

#define PIN_E                 (   1 << 10)

#define PIN_RW                (   1 << 11)

#define PIN_RS                (   1 << 12)

#define PINS_CTRL             (0x07 << 10)

#define PINS_DATA             (0x0F <<  0)

#define PINS_ALL              (PINS_CTRL | PINS_DATA)

const unsigned int SWAP_DATA[16] = { 0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE,

                                     0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};

/* Enable Clock for peripheral driving LCD pins                               */

#define LCD_CLOCK_EN         (RCC->APB2ENR |= (1 << 4)); // enable clock for GPIOC

/* pin E  setting to 0 or 1                                                   */

#define LCD_E(x)              GPIOC->ODR = (GPIOC->ODR & ~PIN_E)  | (x ? PIN_E : 0);

/* pin RW setting to 0 or 1                                                   */

#define LCD_RW(x)             GPIOC->ODR = (GPIOC->ODR & ~PIN_RW) | (x ? PIN_RW : 0);

/* pin RS setting to 0 or 1                                                   */

#define LCD_RS(x)             GPIOC->ODR = (GPIOC->ODR & ~PIN_RS) | (x ? PIN_RS : 0);

/* Reading DATA pins                                                          */

#define LCD_DATA_IN           SWAP_DATA[(((GPIOC->IDR & PINS_DATA) >> 0) & 0x0F)]

/* Writing value to DATA pins                                                 */

#define LCD_DATA_OUT(x)       GPIOC->ODR = (GPIOC->ODR & ~PINS_DATA) | ((SWAP_DATA[x]) << 0);

/* Setting all pins to output mode                                            */

#define LCD_ALL_DIR_OUT       GPIOC->CRL = (GPIOC->CRL & 0xFFFF0000) | 0x00003333; \

                              GPIOC->CRH = (GPIOC->CRH & 0xFFF000FF) | 0x00033300;

 

/* Setting DATA pins to input mode                                            */

#define LCD_DATA_DIR_IN       GPIOC->CRL = (GPIOC->CRL & 0xFFFF0000) | 0x00004444;

/* Setting DATA pins to output mode                                           */

#define LCD_DATA_DIR_OUT      GPIOC->CRL = (GPIOC->CRL & 0xFFFF0000) | 0x00003333;

Posted on December 13, 2012 at 11:03

''I need the pins assignements''

 

It's your  project - so it's up to you  to assign whatever pins are available/suitable/conventient in your  particular application!

aymen
Associate II
Posted on December 13, 2012 at 11:20

I tried but there is no result. i can't write data.

Posted on December 13, 2012 at 12:47

So you've done some thing(s) wrong - in your hardware, or in your software, or both.

Time for you to get checking & debugging...

As clive1 said, there are thousands of example drivers on the internets already!

Posted on December 13, 2012 at 15:33

It would be more effective if you wired up your 8-bit bus with consecutive GPIO pins so that the bus isn't backward like it is for your 4-bit bus.

Perhaps you should look at your board schematic and figure out what pins are free.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jj2
Associate II
Posted on December 13, 2012 at 16:02

Your reversal of the ''normal order'' of the Lcd D-Bus is curious.  (only makes sense if your board GPIO pinout enabled fortuitous connection - via the ''tortured'' bus)

Many, many seek & enjoy the 4 GPIO pin savings when using 4 bits.  And you have that working.  For what good reason do you seek to ''kill'' this working system by moving to 8 bits?

aymen
Associate II
Posted on December 18, 2012 at 14:19

I have à new LCD(phico d-0 94v-0) wich must be configured in 8bits mode in order to write data.

i try with 4bits mode but no results

http://www.datasheetarchive.com/LM2780A2C40HN-datasheet.html

jj2
Associate II
Posted on December 18, 2012 at 17:57

''i try with 4bits mode but no results.''

''No results'' as a diagnosis provides almost NO Value!  Your new Lcd almost certainly includes an HD44780/clone control IC - and all of these are 4 or 8 bit compatible!

Suspect instead that you have an improper contrast voltage (Vo) setting.  If improper - you will not see the pixel field.  It may be that you need some slight negative voltage on this Vo pin - devil in the detail w/in your data sheet.