timadria / u8glib

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

Arduino HW speed enhancement #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This isn't really an issue, just wanted to submit a little trick to achieve 
8MHz on the arduino HW spi.

in the u8g_com_arduino_hw_spi.c file, you can add "SPSR = (1 << SPI2X);" 
underneath the section of code:

SPCR = 0;
      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);

so that it looks like 

SPCR = 0;
      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
SPSR = (1 << SPI2X); 

and it will double the speed of the SPI communications.  Seems to be working 
great and allows me to update the screen much faster for real time 
troubleshooting.

However, I'm playing around on Arduino Mega 2560s and some of them are able to 
use the HW SPI for arduino, and others only work with the SW SPI.  I have no 
clue why this is, but i'm using the 
U8GLIB_NHD27OLED_2X_GR
sometimes the 2560s do all work using the HW spi, but it looks like there's a 
whole lot of noise on the screen and eventually the whole image just craps 
out...

Maybe this can be looked into?

Original issue reported on code.google.com by electric...@gmail.com on 23 Aug 2012 at 3:50

GoogleCodeExporter commented 8 years ago

Original comment by olikr...@gmail.com on 26 Aug 2012 at 4:16

GoogleCodeExporter commented 8 years ago
with my measuments, the speed improvements are very small, In fact i did not 
measure any difference with the dogm128

I have added this code:

#ifdef U8G_HW_SPI_2X
      SPSR = (1 << SPI2X);  /* double speed, issue 89 */
#endif

This switch can be enabled in u8g.h

Original comment by olikr...@gmail.com on 28 Aug 2012 at 8:17

GoogleCodeExporter commented 8 years ago
I did some tests with U8GLIB_NHD27OLED_2X_BW
Clear screen (FPS.pde) is increasd from 6.8 to 7.0
I do not have a mega board so i can not do any testin with the mega board.

The double speed option is now avialable with a define statement.

Original comment by olikr...@gmail.com on 28 Aug 2012 at 8:43