Jump to content

  • Log In with Google      Sign In   
  • Create Account

Photo

Librarie Pt Lcd Hd44780


  • Please log in to reply
3 replies to this topic

#1 OFFLINE   moro

moro

    Membru avansat

  • Membri
  • PipPipPipPip
  • 1,027 posts

Posted 08 May 2014 - 09:05 PM

Are cineva o librarie pt un cotex STM32 ?


  • 0

Cu_reclama

Cu_reclama
  • Membri

#2 OFFLINE   cristi7521

cristi7521

    Membru

  • Membri
  • PipPip
  • 234 posts
  • Locatie:Pitesti

Posted 09 May 2014 - 07:08 AM

Daca ai Keil instalat o gasesti in ...keilARMBoardsKeilMCBSTM32Blinky

Sau o gasesti pe net cautand  LCD_4bit.c mcbstm32

Pt STM32F4 trebuie modificata... sau incercat cu una din cele de mai jos

http://mikrocontroll...s/?page_id=1378

http://kaankandemir....cd-kullanimi-2/


Edited by cristi7521, 09 May 2014 - 07:24 AM.

  • 0

#3 OFFLINE   moro

moro

    Membru avansat

  • Membri
  • PipPipPipPip
  • 1,027 posts

Posted 09 May 2014 - 08:15 AM

Am incercat`o pe prima din http://mikrocontroll...s/?page_id=1378 ,

 

Eu folosesc IAR, am modificat in stm32_ub_lcd_2x16.c pinii pt lcd-ul meu, care e pus pe GPIOD, si mi-a functionat din prima pe stm32f407vg.

 

Multumesc!!

LCD_2X16_t LCD_2X16[] = { // Name   ,PORT , PIN       , CLOCK              , Init  {TLCD_RS ,GPIOD,GPIO_Pin_2 ,RCC_AHB1Periph_GPIOD,Bit_RESET},  {TLCD_E  ,GPIOD,GPIO_Pin_4 ,RCC_AHB1Periph_GPIOD,Bit_RESET},  {TLCD_D4 ,GPIOD,GPIO_Pin_0 ,RCC_AHB1Periph_GPIOD,Bit_RESET},  {TLCD_D5 ,GPIOD,GPIO_Pin_1 ,RCC_AHB1Periph_GPIOD,Bit_RESET},  {TLCD_D6 ,GPIOD,GPIO_Pin_3 ,RCC_AHB1Periph_GPIOD,Bit_RESET},  {TLCD_D7 ,GPIOD,GPIO_Pin_5,RCC_AHB1Periph_GPIOD,Bit_RESET},};

  • 0

Cu_reclama

Cu_reclama
  • Membri

#4 OFFLINE   moro

moro

    Membru avansat

  • Membri
  • PipPipPipPip
  • 1,027 posts

Posted 20 June 2014 - 06:27 AM

Dupa ce am migrat un proiect din C in C++ cu libraria neamtzului am intampinat niste probleme la compilare, am incercat si alte librarii dar fara success.

 

Ma enervasem, asa ca mi-am construit propria librarie pt afisare pe display :laughing3:

 

L-am incercat pe un 20x4 si merge brici, nu l-am incercat pe un 16x2 care este mai comun in randul utilizatorilor, insa teoretic ar trebui sa functioneze, adresele fiind aceleasi

Codul este compatibil atat in c cat si c++, e mai "tzaraneste" facut, pt a evita erori intre cele doua

 

Mai jos este codul, poate va fi de folos cuiva.  teoretic ar trebui sa mearga pe orice stm32f4xx( pe discovery f4 cu stm32f407 s-a testat si e ok), dar si pe un F3

 

exemplu

int main() {lcd_init();char txt[10];int aa;aa=33;lcd_char(1,1,"Ana are mere");lcd_char(2,1,"unul e doar becali!!");sprintf(txt,"%d",aa);lcd_char(3,15,txt);}
///// DEFINE YOUR GPIO PORT AND GPIO PIN #define LCD_Port GPIOx /* Make sure you also change in lcd_init() "RCC_AHB1Periph_GPIOx" */#define RS GPIO_Pin_x#define EN GPIO_Pin_x#define D4 GPIO_Pin_x#define D5 GPIO_Pin_x#define D6 GPIO_Pin_x#define D7 GPIO_Pin_x///// END OF DEFINEvoid lcd_delay(volatile uint32_t nCount) // delay routine{ while(nCount--)  {  }}void en_toggle(){    GPIO_SetBits(LCD_Port,EN); // make sure EN is high  lcd_delay(1000);  GPIO_ResetBits(LCD_Port,EN); // make sure EN is low  lcd_delay(1000);}void lcd_data(uint8_t cmd) {uint8_t bit7;  uint8_t bit6;uint8_t bit5;uint8_t bit4;uint8_t bit3;uint8_t bit2;uint8_t bit1;uint8_t bit0;bit7 =(cmd>>7)&0x01;bit6 =(cmd>>6)&0x01;bit5 =(cmd>>5)&0x01;bit4 =(cmd>>4)&0x01;bit3 =(cmd>>3)&0x01;bit2 =(cmd>>2)&0x01;bit1 =(cmd>>1)&0x01;bit0 =cmd&0x01;GPIO_SetBits(LCD_Port,RS); // make sure RS is high ( data mode)if(bit7==1) GPIO_SetBits(LCD_Port,D7); else GPIO_ResetBits(LCD_Port,D7);if(bit6==1) GPIO_SetBits(LCD_Port,D6); else GPIO_ResetBits(LCD_Port,D6);if(bit5==1) GPIO_SetBits(LCD_Port,D5); else GPIO_ResetBits(LCD_Port,D5);if(bit4==1) GPIO_SetBits(LCD_Port,D4); else GPIO_ResetBits(LCD_Port,D4);en_toggle();if(bit3==1) GPIO_SetBits(LCD_Port,D7); else GPIO_ResetBits(LCD_Port,D7);if(bit2==1) GPIO_SetBits(LCD_Port,D6); else GPIO_ResetBits(LCD_Port,D6);if(bit1==1) GPIO_SetBits(LCD_Port,D5); else GPIO_ResetBits(LCD_Port,D5);if(bit0==1) GPIO_SetBits(LCD_Port,D4); else GPIO_ResetBits(LCD_Port,D4);en_toggle();}void lcd_cmd(uint8_t cmd) {uint8_t bit7;  uint8_t bit6;uint8_t bit5;uint8_t bit4;uint8_t bit3;uint8_t bit2;uint8_t bit1;uint8_t bit0;bit7 =(cmd>>7)&0x01;bit6 =(cmd>>6)&0x01;bit5 =(cmd>>5)&0x01;bit4 =(cmd>>4)&0x01;bit3 =(cmd>>3)&0x01;bit2 =(cmd>>2)&0x01;bit1 =(cmd>>1)&0x01;bit0 =cmd&0x01;GPIO_ResetBits(LCD_Port,RS); // make sure RS is low ( command mode)if(bit7==1) GPIO_SetBits(LCD_Port,D7); else GPIO_ResetBits(LCD_Port,D7);if(bit6==1) GPIO_SetBits(LCD_Port,D6); else GPIO_ResetBits(LCD_Port,D6);if(bit5==1) GPIO_SetBits(LCD_Port,D5); else GPIO_ResetBits(LCD_Port,D5);if(bit4==1) GPIO_SetBits(LCD_Port,D4); else GPIO_ResetBits(LCD_Port,D4);en_toggle();if(bit3==1) GPIO_SetBits(LCD_Port,D7); else GPIO_ResetBits(LCD_Port,D7);if(bit2==1) GPIO_SetBits(LCD_Port,D6); else GPIO_ResetBits(LCD_Port,D6);if(bit1==1) GPIO_SetBits(LCD_Port,D5); else GPIO_ResetBits(LCD_Port,D5);if(bit0==1) GPIO_SetBits(LCD_Port,D4); else GPIO_ResetBits(LCD_Port,D4);en_toggle();}void lcd_init(){    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE); // Here Chage x to same port declared at #define LCD_PORT    GPIO_InitTypeDef  GPIO_InitStructure;      GPIO_InitStructure.GPIO_Pin =  EN | RS | D4 | D5 | D6 | D7;    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;    GPIO_Init(GPIOE, &GPIO_InitStructure);     GPIO_ResetBits(LCD_Port,RS); // make sure RS is low     lcd_delay(100000); GPIO_SetBits(LCD_Port,D4); GPIO_SetBits(LCD_Port,D5); GPIO_ResetBits(LCD_Port,D6); GPIO_ResetBits(LCD_Port,D7);en_toggle();  lcd_delay(100000);en_toggle();  lcd_delay(100000);en_toggle();  lcd_delay(100000);GPIO_ResetBits(LCD_Port,D4); GPIO_SetBits(LCD_Port,D5); GPIO_ResetBits(LCD_Port,D6); GPIO_ResetBits(LCD_Port,D7);en_toggle();  lcd_delay(100000);lcd_cmd(0x28);lcd_cmd(0x06);lcd_cmd(0x0C);lcd_cmd(0x01);lcd_delay(100000);} void lcd_cursor(uint8_t line,uint8_t row){  uint8_t pp,dd;  if(line==1){ pp=0;}  if(line==2){ pp=64;}  if(line==3){ pp=20;}  if(line==4){ pp=84;}  dd=pp+row-1;  dd^=128;  lcd_cmd(dd);}   void lcd_char(uint8_t line,uint8_t row,char *cc){ lcd_cursor(line,row);  while (*cc != 0) {    lcd_data(*cc);    cc++;  } 

  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users