Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

showing the data on characteristic lcd 2*16 with microblaze on fpga .

Status
Not open for further replies.

moein0114

Newbie level 6
Newbie level 6
Joined
Jul 1, 2015
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
92
hi , i am using the microblaze to calculate some thing and after that i want to show it on the lcd i have on my board . i ddidnt know exactly how to do it , so i searched and now i want to use this code to run the lcd for now :

Code:
#include<stdio.h>
#include<xparameters.h>
#include<xgpio.h>
XGpio e,rs,rw,lcd_data;
char reverse(char data)
{
     int i;
     int temp1;
     int temp2=0;
     for(i=0;i<8;i++)
     {
         temp1 = (data>>i)&1;
         temp2+= temp1 << (7-i);
     }
     return temp2;
}

void delay(int counter)
{
       while(counter) counter--;
}

void gpio_init (void)
{
     XGpio_Initialize(&e, XPAR_E_DEVICE_ID);
     XGpio_Initialize(&rs, XPAR_RS_DEVICE_ID);
     XGpio_Initialize(&rw, XPAR_RW_DEVICE_ID);
     XGpio_Initialize(&lcd_data, XPAR_DATA_IN_DEVICE_ID);
     /*Set the all GPIOs as output*/
     XGpio_SetDataDirection(&e,1,0);
     XGpio_SetDataDirection(&rs,1,0);
     XGpio_SetDataDirection(&rw,1,0);
     XGpio_SetDataDirection(&lcd_data,1,0);
}
void lcd_command(char i)
{
     XGpio_DiscreteWrite(&lcd_data,1,reverse(i));
     XGpio_DiscreteWrite(&rs, 1, 0);
     XGpio_DiscreteWrite(&e, 1, 1);
     XGpio_DiscreteWrite(&e, 1, 0);
     delay(200000);
}

void lcd_write(char i)
{
      XGpio_DiscreteWrite(&lcd_data, 1, reverse(i));
      XGpio_DiscreteWrite(&rs, 1, 1);
      XGpio_DiscreteWrite(&e, 1, 1);
      XGpio_DiscreteWrite(&e, 1, 0);
      delay(200000);
}

void cursor(int row, int column)
{
      if(row==1)
            lcd_command(0x80|(column-1));
      if (row==2)
           lcd_command(0x80|(0x40+(column-1)));
}

int main(void)
{
       gpio_init();
       XGpio_DiscreteWrite(&rw,1,0);
       delay(20000);
 lcd_command(0x28);  // in dasture chek shode hastesho malume chi b chie , faghat bahse cursor mimuen chie ????
       lcd_command(0x01);
       lcd_command(0x06);
       lcd_command(0x0F);

       lcd_write('F');
       lcd_write('P');
       lcd_write('G');
       lcd_write('A');
       cursor(2,1);
       lcd_write('C');
       lcd_write('E');
       lcd_write('N');
       lcd_write('T');
       lcd_write('E');
       lcd_write('R');
       return 0;
}

i have problems ,
does any body know , what is reverse() doing here ?
i am using characteristic lcd 2*16 and i have considered the commands for my lcd kind .
i just have problem with reverse ().
what am i missing here ?
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top