Rei Vilo 695 Posted June 28, 2013 Share Posted June 28, 2013 Problem solved! I'd like to write and read the 8 bits of PB port on the LaunchPad Stellaris at once. On the Arduino Meag2560, I can write and read the values of an 8-bit port, for example PORTC. void LCD_HI32::_writeParallelLCD88(uint8_t dataHigh8, uint8_t dataLow8) { #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) PORTA = dataHigh8; PORTC = dataLow8; pulse_low(_portWR, _bitWR); #else //#error Platform not supported. #endif } void LCD_HI32::_readParallelLCD88(uint8_t &dataHigh8, uint8_t &dataLow8) { #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) pulse_low(_portRS, _bitRS); dataHigh8 = PORTA; dataLow8 = PORTC; #else //#error Platform not supported. #endif } For the MSP430, uint8_t value = 2; P1OUT = value; value = P1IN; What are the corresponding variables for Stellaris? Thank you. Quote Link to post Share on other sites
chicken 630 Posted June 28, 2013 Share Posted June 28, 2013 For Stellaris (untested - you might need some type casting to make the compiler happy as GPIO registers are 32bit) uint8_t value = 2; GPIO_PORTB_DATA_R = value; value = GPIO_PORTB_DATA_R; The register for direction is GPIO_PORTB_DIR_R. The include file lm4f120h5qr.h defines all the registers. Rei Vilo 1 Quote Link to post Share on other sites
jkabat 0 Posted June 28, 2013 Share Posted June 28, 2013 @Mention, Here is what I use for my LCD driver. Note the last line. Remember HWREG is your friend. A good way to do fast digital I/O. //========================================// Port and bitmask used for 8-bit data bus#define LCD_DATA_PERIPH SYSCTL_PERIPH_GPIOB#define LCD_DATA_BASE GPIO_PORTB_BASE#define LCD_DATA_PINS 0xFF// Ports and pins used for control#define LCD_CS_PERIPH SYSCTL_PERIPH_GPIOA#define LCD_CS_BASE GPIO_PORTA_BASE#define LCD_CS_PIN GPIO_PIN_7#define LCD_CD_PERIPH SYSCTL_PERIPH_GPIOA#define LCD_CD_BASE GPIO_PORTA_BASE#define LCD_CD_PIN GPIO_PIN_6#define LCD_WR_PERIPH SYSCTL_PERIPH_GPIOA#define LCD_WR_BASE GPIO_PORTA_BASE#define LCD_WR_PIN GPIO_PIN_5#define LCD_RD_PERIPH SYSCTL_PERIPH_GPIOA#define LCD_RD_BASE GPIO_PORTA_BASE#define LCD_RD_PIN GPIO_PIN_4#define LCD_RST_PERIPH SYSCTL_PERIPH_GPIOC#define LCD_RST_BASE GPIO_PORTC_BASE#define LCD_RST_PIN GPIO_PIN_7#define LCD_BKLT_PERIPH SYSCTL_PERIPH_GPIOD#define LCD_BKLT_BASE GPIO_PORTD_BASE#define LCD_BKLT_PIN GPIO_PIN_6#define LCD_CS_IDLE HWREG(LCD_CS_BASE + GPIO_O_DATA + (LCD_CS_PIN << 2)) = LCD_CS_PIN;#define LCD_CS_ACTIVE HWREG(LCD_CS_BASE + GPIO_O_DATA + (LCD_CS_PIN << 2)) = 0;#define LCD_CD_DATA HWREG(LCD_CD_BASE + GPIO_O_DATA + (LCD_CD_PIN << 2)) = LCD_CD_PIN;#define LCD_CD_COMMAND HWREG(LCD_CD_BASE + GPIO_O_DATA + (LCD_CD_PIN << 2)) = 0;#define LCD_WR_IDLE HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = LCD_WR_PIN;#define LCD_WR_ACTIVE HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = 0;#define LCD_RD_IDLE HWREG(LCD_RD_BASE + GPIO_O_DATA + (LCD_RD_PIN << 2)) = LCD_RD_PIN;#define LCD_RD_ACTIVE HWREG(LCD_RD_BASE + GPIO_O_DATA + (LCD_RD_PIN << 2)) = 0;#define LCD_RST_IDLE HWREG(LCD_RST_BASE + GPIO_O_DATA + (LCD_RST_PIN << 2)) = LCD_RST_PIN;#define LCD_RST_ACTIVE HWREG(LCD_RST_BASE + GPIO_O_DATA + (LCD_RST_PIN << 2)) = 0;#define LCD_BKLT_ON HWREG(LCD_BKLT_BASE + GPIO_O_DATA + (LCD_BKLT_PIN << 2)) = LCD_BKLT_PIN;#define LCD_BKLT_OFF HWREG(LCD_BKLT_BASE + GPIO_O_DATA + (LCD_BKLT_PIN << 2)) = 0;#define LCD_DATA_WRITE(ucByte) { HWREG(LCD_DATA_BASE + GPIO_O_DATA + (LCD_DATA_PINS << 2)) = (ucByte); } Rei Vilo 1 Quote Link to post Share on other sites
igor 163 Posted June 28, 2013 Share Posted June 28, 2013 Not sure in Energia, using stellarisware you read it as GPIOPinRead(GPIO_PORTB_BASE, 0xFF) which translates to (HWREG( GPIO_PORTB_BASE + (GPIO_O_DATA + (0xFF << 2)))); Edit - ignore this post, others answered while it was sitting in my browser. Don't see a way to delete. Quote Link to post Share on other sites
chicken 630 Posted June 29, 2013 Share Posted June 29, 2013 I usually do what @@jkabat says (looks like we used the same template for our display projects ), but thought @@Rei Vilo was looking for the straight forward version. In the end, both gets compiled into the same machine code (assuming all 8 bits are read/written). Quote Link to post Share on other sites
Rei Vilo 695 Posted June 29, 2013 Author Share Posted June 29, 2013 Thank you very much for the clear indications and explanations. As rightly pointed by @@chicken, the following pre-processing statement is required: #include "inc/lm4f120h5qr.h" Without going as deep as recommended by @@jkabat, the functions mentioned by @@igor are available in Energia in the gpio.c library: GPIODirModeSet(unsigned long ulPort, unsigned char ucPins, unsigned long ulPinIO) GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal) GPIOPinRead(unsigned long ulPort, unsigned char ucPins) Yes, this is for a 8-bit parallel screen Quote Link to post Share on other sites
Rei Vilo 695 Posted July 10, 2013 Author Share Posted July 10, 2013 On Energia, this line of code is required to have the port working fine: GPIOPadConfigSet(GPIO_PORTB_BASE, 0xff, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); I can now start exploring the Kentec 3.5" display. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 14, 2013 Author Share Posted July 14, 2013 Here is what I use for my LCD driver. Note the last line. Remember HWREG is your friend. A good way to do fast digital I/O. Thank you @@jkabat for pointing me on this interesting direction. At first, I was afraid by such low-level HWREG instructions but once I get used to them, I really enjoy how fast they are! Quote Link to post Share on other sites
jkabat 0 Posted July 15, 2013 Share Posted July 15, 2013 Glad to be of service. John Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.