2013-12-26 05:38 AM
Guys,
How can I define PORTE on STM32 as D0-D7 on LCD? I have more than 8bits on PORTE, on AVR for example PORTA = data, how can I do it on STM32 ? any ideas ? thanks2013-12-26 07:23 AM
Hi rick,
You can refer to ST library.The ports are defined as GPIOA, GPIOB, GPIOC....and evey port has 15 pins: Pin 0, Pin 1,.... Pin 152013-12-26 07:44 AM
GPIOE->BSRR = data | ((~data & 0xFF) << 16); //??
or GPIOE->ODR = (GPIOE->ODR & 0xFF00) | data;2013-12-26 07:57 AM
I wrote, please have a look and correct me :
//LCD Define #define lcd_data_pin GPIOE #define rs GPIO_Pin_8 #define rw GPIO_Pin_9 #define en GPIO_Pin_10 void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; //RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE); RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOE, &GPIO_InitStructure); } void lcd_cmd(unsigned char cmd){ //lcd_data_pin = cmd ; GPIO_Write(lcd_data_pin, cmd); GPIO_WriteBit(lcd_data_pin, en, Bit_SET); GPIO_WriteBit(lcd_data_pin, rs, Bit_RESET); GPIO_WriteBit(lcd_data_pin, rw, Bit_RESET); //en=1; //rs=0; //rw=0; vTaskDelay(10); GPIO_WriteBit(lcd_data_pin, en, Bit_RESET); //en=0; }