Eugeniuschang / u8glib

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

HW SPI on Arduino MEGA 2560 and ST7920 #164

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open an example sketch, U8GLIB_ST7920_128X64_4X u8g(53);
2. Compile and upload
3. Bang head on wall

It works on Arduino UNO with CS pin 10, but it doesn't on Arduino MEGA 2560. 
I'm using SCK at pin 52, MOSI at 51 and tried the CS (SS) pin at both 53 and 10.

The connections are correct, so I guess it's a hardware limitation?

Original issue reported on code.google.com by giann...@gmail.com on 6 May 2013 at 1:50

GoogleCodeExporter commented 8 years ago
HW SPI is not supported (did you try SW SPI also?)

To make HW SPI working, you need to patch
u8g_com_arduino_st7920_hw_spi.c
Probably lines 120 to 125 need to be updated

Original comment by olikr...@gmail.com on 6 May 2013 at 5:56

GoogleCodeExporter commented 8 years ago
Why doesn't it support SPI using the u8g_com_arduino_hw_spi.c file?

Original comment by giann...@gmail.com on 6 May 2013 at 6:44

GoogleCodeExporter commented 8 years ago
I do not own an Arduino Mega :-(

You could patch the file, do the testing and send the result back to me... then 
i can add the modification.

Original comment by olikr...@gmail.com on 6 May 2013 at 8:31

GoogleCodeExporter commented 8 years ago
It is a really easy fix, all I did is changing the pin numbers. It works! I 
can't create a patch file right now, but here are the lines I changed:

      DDRB |= _BV(2);          /* D0, MOSI */
      DDRB |= _BV(1);          /* SCK */
      DDRB |= _BV(0);       /* slave select */

      PORTB &= ~_BV(2);        /* D0, MOSI = 0 */
      PORTB &= ~_BV(1);        /* SCK = 0 */

If you need further testing, I'll be glad to help!

Original comment by giann...@gmail.com on 6 May 2013 at 9:00

GoogleCodeExporter commented 8 years ago
c code has been updated (Arduino variant uses the arduino pin definitions now)

ToDo
Test wether the Arduino Uno still works with HW SPI.
Test case: Use HW SPI with ST7920 (HelloWorld)

Original comment by olikr...@gmail.com on 7 May 2013 at 7:31

GoogleCodeExporter commented 8 years ago
still ok, tested during performance updates

Original comment by olikr...@gmail.com on 5 Jun 2013 at 8:08