Arduino LCD Shield converted to avrgcc...

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone have the arduino lcd shield? I'm trying to configure Peter Fleury's library to control the lcd screen but nothing doing.

The schematic is here: http://www.sainsmart.com/media/wysiwyg/Schematic.jpg

The screen does work if I use the arduino library.

It's gotta be something simple I'm missing...

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look at the arduino code - its for avr-gcc as that is what the arduino uses.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't really know how the arduino code works hence my effort here. There's a lot of abstraction there that I'm not quite good enough to untangle.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its simpler than you think. Find the library code and you're nearly done.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have the LCD shield sitting on an Arduino "base board"?
If so, which?
If not, show schematics on how you wired the LCD shield up to the AVR.

Quote:
nothing doing

Any more elaborate description of symptoms?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fleurys library seems to make use of the Busy flag, and for that to work the R/W pin on the LCD needs to be connected. The schematic you provided has it grounded.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah - I noticed that Fleury needed that pin defined in the header file but I also read elsewhere that that pin is often grounded so I figured no big deal.

I'll look through his library and see if I can figure out how to disable the busy flag.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He only uses the read-functionality in one place, monitoring the Busy flag. Replace his wait for the Busy flag to clear with a sufficient wait.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do see the lcd_read and lcd_write function set the rw pin high or low respectively in order to proceed but I don't see anywhere where it is actually reading the status of that pin. In fact, that pin is just an output.

Can you tell me where you see that monitoring of the busy flag?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan has got links to several libraries on his site.

Look at code from Peter Danegger (danni)

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Johan has got links to several libraries on his site.

Look at code from Peter Danegger (danni)

David.

Thanks. Danni's code worked perfectly the first time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Johan has got links to several libraries on his site.

Look at code from Peter Danegger (danni)

David.

Thanks. Danni's code worked perfectly the first time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I do see the lcd_read and lcd_write function set the rw pin high or low respectively in order to proceed but I don't see anywhere where it is actually reading the status of that pin.

That pin is an input to the LCD, to tell the LCD controller to be in read mode or in write mode. On your LCD shield the R/W pin is constantly pulled low by hardware arrangements, so it is always in write mode.

All you need to do is to replace the code in Fleurys library that actually puts an LCD into read mode with something else that does the same thing.

So... (All below from memory - I will not look into the code again):

You look for where in the code it is set high. That is in one place only.

You look at what is there. One function that waits for the busy flag to clear.

You now look at what places THAT function is used, and realize that the best thing to do is to leave all those calls as they where and simply replace the innards of the Busy-wait function with your timed delay.

Can you tell me where you see that monitoring of the busy flag?

It's right there, called _LCD_wait_busy or some such.

Or you just stay with Dannis code. :D

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've already deleted that library and moved on but thanks for the help. I did a search for the word "busy" and all the other times that rw pin is discussed and didn't see anything obvious.

I realize the pin is an input to the LCD, the point is that it is an output from the AVR so the AVR wont be polling it or waiting on it.

No biggy, the other library works fine anyhow.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An I allowed to show you how I do it with a diff compiler?

//---------text lcd routines----------------------
//segment data in pd4567

//#define RWLO() PORTB &= ~0x02 //gnd
//#define RWHI() PORTB |=  0x02

#define RSLO() PORTB &= ~0x01 //d8 pb0
#define RSHI() PORTB |=  0x01

#define ENLO() PORTB &= ~0x02 //d9 pb1
#define ENHI() PORTB |=  0x02

//------------------------
void lcddel10us(int n){
//delay 10 usec
int j;

  while(n--) {
    j=26;
    while(j--){}; //2600=1ms, 260=100usec, 26=10usec
  }
}

//--------------------
void putnib(char c){
//lo bytes of d to hi bits of port

  PORTD = (PORTD & 0x0f)|(c << 4);
  ENHI();
  asm("nop"); //8x62=500ns
  asm("nop");
  asm("nop");
  asm("nop");
  asm("nop");
  asm("nop");
  asm("nop");
  asm("nop");
  ENLO();
}

//--------------------
void lcdputbyte(unsigned char c){
//either data or cmd byte, previously set

//  RWLO(); //write
  putnib(c >> 4);    //hi nib
  putnib(c & 0x0f);  //lo nib
  lcddel10us(5);
}

//--------------------
void lcdcmdbyte(unsigned char c){
//cmd byte

  RSLO(); //command
  lcdputbyte(c);
}

//--------------------
void lcddatabyte(unsigned char c){
//data byte

  RSHI();  //data
  lcdputbyte(c);
}

//----------------
void lcdcls(void){
//clear lcd screen    1.64ms

  lcdcmdbyte(0x01);
  lcddel10us(165);
}

//--------------------------------------
void lcdgotoxy(unsigned char column, unsigned char line){
//position cursor  top line chars 0-39, 2nd line 40-79
unsigned char addr;

  addr = (line * 64) + column;
  lcdcmdbyte(addr | 0x80);
}

//----------------
void lcdcursoron(void){
//cursor on

  lcdcmdbyte(0x0e);
}

//----------------
void lcdcursoroff(void){
//cursor off

  lcdcmdbyte(0x0c);
}

//------------------
void lcdputc(char c){
//put c

  lcddatabyte(c);
}

//------------------
void lcdcputs(__flash char *ptr){
//put rom string at ptr

  while(*ptr != 0x00){
    lcdputc(*ptr++);
  }  
}

//------------------
void lcdputs(char *ptr){
//put ram string at ptr

  while(*ptr != 0x00){
    lcdputc(*ptr++);
  }  
}

#if 0
//-------------------------------------------------
//custom chars
// [ ] 0
// [ ]

// [*] 1
// [ ]

// [ ] 2
// [*]

// [*] 3
// [*]

__flash unsigned char vu0[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
__flash unsigned char vu1[8]={0x1f,0x1f,0x1f,0x00,0x00,0x00,0x00,0x00};
__flash unsigned char vu2[8]={0x00,0x00,0x00,0x00,0x1f,0x1f,0x1f,0x00};
__flash unsigned char vu3[8]={0x1f,0x1f,0x1f,0x00,0x1f,0x1f,0x1f,0x00};

//-------------------
void initcustomchars(void){
//init special chars
unsigned char n;

  lcdcmdbyte(0x40);
  for(n=0; n < 8; n++){
    lcdcmdbyte(0x40+vu0[n]);
  }
  for(n=0; n < 8; n++){
    lcdcmdbyte(0x40+vu1[n]);
  }
  for(n=0; n < 8; n++){
    lcdcmdbyte(0x40+vu2[n]);
  }
  for(n=0; n < 8; n++){
    lcdcmdbyte(0x40+vu3[n]);
  }
}
#endif

//------------------
void lcdinit(void){
//init lcd 4 bit mode

  lcddel10us(1500); //15000us
  lcdcmdbyte(0x38); //8 bit 2 lines
  lcddel10us(410);  //4100us
  lcdcmdbyte(0x28); //4 bit 2 lines
  lcddel10us(10);   //100us
  lcdcmdbyte(0x28); //4 bit 2 lines
  lcdcmdbyte(0x0c); //display on    40usec
  lcdcmdbyte(0x06); //cursor on, increment  40usec
  lcdcmdbyte(0x80); //cg addr 0     40usec
  lcdcmdbyte(0x40); //data addr 0   40usec
}

//---------analog buttons on dfrobot shield---------------
//-------------------------------select left up   dn  right
__flash unsigned int buttondat[5]={740, 504, 144, 330, 0};
unsigned char but,butl;
unsigned char butos;
//---------------------
void readanalogbuttons(void){
unsigned char n;
unsigned int tmp,err;

  tmp=readadchan(0);  //read analog value
  but=0xff;
  for(n=0; n < 5; n++){
    err = abs(buttondat[n]-tmp);
    if(err < 80) but=n;
  }
  butos=(but != 0xff) && (butl == 0xff);
  butl=but;
}

//--------------------
void buttonloop(void){
//read analog buttons on resistor chain
unsigned char c;

  cprintf("analog buttons\n");
  c=0;
  while(c!='q'){
    if(kbhit()){
      c=getchar();
    }
    readanalogbuttons();  
    if(butos){
      cprintf("%3d \r",but);
    }	
    _StackCheck(); //debug
    delnms(5);  
  }
}

//-----------------------------
void lcdsplash(void){
//power on splash screen on lcd
	
  lcdcls();
	//        0123456789012345
  lcdcputs(" SPEAKER WATTS  ");
  lcdgotoxy(0,1);
  lcdcputs("    11/28/13    ");
}


Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob, need help with custom char loading?