How to write 8-bit data parallel on port?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to write 8-bit data parallel on port?

1,282 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by anze87 on Sat Dec 14 05:48:07 MST 2013
Hello!

I am new at LPC programming, and I need your help. I am writting LCD functions for LCD ST7735 with parallel 8-bit interface. What is correct and the fastest way for example, if I want write some 8-bit data on pins from PIO_0 to PIO_7? I must probablly use masking. Can Anyone please give clear example of that? I am using LPC1343CodeBase.

Thanks for your help!
Labels (1)
0 Kudos
Reply
2 Replies

1,168 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by anze87 on Sun Dec 15 08:02:12 MST 2013
Thanks for help. Is something like this correct? I have data from PIO2_1 to PIO2_8 for example.

#define LCD_DATA_PORT         2     // 8-Pin Data Port
#define LCD_DATA_PIN1         1
#define LCD_DATA_PIN2         2
#define LCD_DATA_PIN3         3
#define LCD_DATA_PIN4         4
#define LCD_DATA_PIN5         5
#define LCD_DATA_PIN6         6
#define LCD_DATA_PIN7         7
#define LCD_DATA_PIN8         8
#define LCD_DATA_MASK         0x000001FE
#define LCD_DATA_OFFSET       1    // Offset = PIN1

#define GPIO_GPIO2_BASE                           (0x50020000)

#define LCD_GPIO2DATA_DATA        (*(pREG32 (GPIO_GPIO2_BASE + (LCD_DATA_MASK << 2))))

/**************************************************************************/
//Writes the supplied 8-bit data using an 8-bit interface
/**************************************************************************/
void LcdWriteData(uint8_t data)
{
//chip select
CLR_CS;
//send data
SET_CD;

  CLR_WR;
  LCD_GPIO2DATA_DATA = data << LCD_DATA_OFFSET;
  SET_WR;

  SET_CS;
}
/**************************************************************************/

0 Kudos
Reply

1,168 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Sat Dec 14 17:31:52 MST 2013
Study Chapter 7 and 9 in the LPC13xx User Manual (UM10375). The relevant steps are:

1. Set the IOCON values so that each pin you are using is configured as a GPIO pin and does not have a special function. (See Table 99 onwards)

2. Set the relevant bits in the GPIO data direction register so that each pin you are using is configured as an output pin. (See Table 150)

3. Set the relevant bits in the GPIODATAMASK register so that only the pins you are using are affected by read-write operations (see Section 9.5.1)

4. Write your data to the relevant GPIODATA register (see section 9.4.1).


0 Kudos
Reply