rmdimin / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

Parallel Mode ST7920 + ATmega32 #296

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Software SPI is working well, but to slow (0,75FPS) for my application
2. I'm not able to init parallel mode

What is the expected output? What do you see instead?
-I expect the same Output as the working init with SW SPI
-Now i se only a blank screen

What version of the product are you using? On what operating system?
1.14 @ AVR Studio 6.2

Please provide any additional information below.

-ATmega32 @ 16MHz
-Only output to Display implementet in main.

This is my init:

#define di PB0 //PIN4 data selection (R/S)
#define rw PB1 //PIN5 read or write selection (R/W)
#define en PB2 //PIN6 enable (E)
#define d0 PA0 //PIN7
#define d1 PA1 //PIN8
#define d2 PA2 //PIN9
#define d3 PA3 //PIN10
#define d4 PA4 //PIN11
#define d5 PA5 //PIN12
#define d6 PA6 //PIN13
#define d7 PA7 //PIN14
               //PIN15 PSB set HIGH (parallel)
u8g_Init8Bit(&u8g, &u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, 
en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, U8G_PIN_NONE);

Thanks in advance.

Thank you for this great lib.

Best regards,
garphi

Original issue reported on code.google.com by g4r...@gmail.com on 6 Nov 2014 at 10:46

GoogleCodeExporter commented 8 years ago
How are PB0, PB1, etc defined? U8glib uses a different notation.

Original comment by olikr...@gmail.com on 7 Nov 2014 at 5:43

GoogleCodeExporter commented 8 years ago
Thx for your fast reply.

The DDRA is set as output (0xFF) 
and DDRB PINB0-2 is set as output (0x07)

PA/B is defined in iom32.h as follows:
/* PORTA */
#define PA7     7
#define PA6     6
#define PA5     5
#define PA4     4
#define PA3     3
#define PA2     2
#define PA1     1
#define PA0     0

/* PORTB */
#define PB7     7
#define PB6     6
#define PB5     5
#define PB4     4
#define PB3     3
#define PB2     2
#define PB1     1
#define PB0     0

I got a second question (i can create a new issue if u want):
I want to speed up the main cycle, although i rewrote the LCD Output like this.
But this does not seem to be quite perfect. The first 5 or 6 lines won't be 
updatet (they're left blank)

void UpdateLCD(void)
{
  static uint8_t firstDraw = 0;

  if (!firstDraw)
  {
    u8g_FirstPage(&u8g);
  }
  if (u8g_NextPage(&u8g) || (!firstDraw))
  {
    DrawLCDobj(); 
    firstDraw = 1;
  }   
  else
  {
    TimerArray(0, set, 100);                    //Display Update-Zeit in Timer-Array 0
    firstDraw = 0;
  } 
}//end UpdateLCD

Best regards,
garphi

Original comment by g4r...@gmail.com on 7 Nov 2014 at 2:30

GoogleCodeExporter commented 8 years ago
As arguments for u8glib, you must use the PN() macro. See the examples: 
PN(portnumber, pinnumber)
Where portnunmber 0=Port A, 1=Port B and pinnumber is a value between 0 and 7

In your update procedure, you must call DrawLCDobj() before u8g_NextPage()

Maybe like this (not tested):
void UpdateLCD(void)
{
  static uint8_t firstDraw = 1;
  if (firstDraw <> 0)
  {
    u8g_FirstPage(&u8g);
  }
  DrawLCDobj(); 
  if (u8g_NextPage(&u8g) == 0)
  {
    firstDraw = 1;
  }   
  else
  {
    firstDraw = 0;
  } 
}//end UpdateLCD

Original comment by olikr...@gmail.com on 7 Nov 2014 at 7:23

GoogleCodeExporter commented 8 years ago
Thank you very much.
This has solved both of my issues.

I found my mistake. The AVR makros are used to define Ports like this:
PORTA |= (1<<PA5) to set PORTA5 high, where "PA5" shifts to the right position.

With your explanation how to use PN procedure the parallel mode works fine.
Here is my working code:

  #define di PN(1, 0) //PIN4 data selection (R/S)
  #define rw PN(1, 1) //PIN5 read or write selection (R/W)
  #define en PN(1, 2) //PIN6 enable (E)
  #define d0 PN(0, 0) //PIN7
  #define d1 PN(0, 1) //PIN8
  #define d2 PN(0, 2) //PIN9
  #define d3 PN(0, 3) //PIN10
  #define d4 PN(0, 4) //PIN11
  #define d5 PN(0, 5) //PIN12
  #define d6 PN(0, 6) //PIN13
  #define d7 PN(0, 7) //PIN14
                      //PIN15 PSB set HIGH (parallel)
  u8g_Init8Bit(&u8g, &u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, U8G_PIN_NONE);

your version of UpdateLCD(void) works!
Thanks for the information that you must call DrawLCDobj() before u8g_NextPage()

Best regards ,
garphi

Original comment by g4r...@gmail.com on 8 Nov 2014 at 7:56

GoogleCodeExporter commented 8 years ago
ok, good, i will close this issue if you have no further questions.

Original comment by olikr...@gmail.com on 8 Nov 2014 at 8:09

GoogleCodeExporter commented 8 years ago
You can close this.

Original comment by g4r...@gmail.com on 8 Nov 2014 at 8:11

GoogleCodeExporter commented 8 years ago

Original comment by olikr...@gmail.com on 13 Dec 2014 at 6:00