Created Mon, 25 Jun 2012 15:43:05 +0000 by nik999389
Mon, 25 Jun 2012 15:43:05 +0000
Hey everyone! I recently bought an OLED module from sparkfun and I am trying to interface with it. Currently I'm looking at a library for the same OLED but it's using an Atmega 644p. Here is the link to the Code:
[url]http://www.idleloop.com/robotics/OLEDsample/[/url]
There really isn't much to change in the code. Most of it is High Level. The only thing that really needs to be looked at is the port registers and when they get set and this has all been scrunched up together at the top of the OLED.cpp file.
Here is that code:
/* data */
#define SetData(x) (PORTA = (x)) // A7-A0 is OLED D7-D0
#define GetData() (PINA)
#define GetData8() (PINC & 0x80) // C7 is OLED D8
#define Data8High() (PORTC |= 0x80)
#define Data8Low() (PORTC &= ~0x80)
#define SetupDataOutput() { DDRA = 0xff; DDRC |= 0x80; }
#define SetupDataInput() { PORTA = 0; DDRA = 0; PORTC &= ~0x80; DDRC &= ~0x80; }
/* control */
#define EHigh() (PORTC |= 0x40) // C6
#define ELow() (PORTC &= ~0x40)
#define RWHigh() (PORTC |= 0x20) // C5
#define RWLow() (PORTC &= ~0x20)
#define CSHigh() (PORTC |= 0x10) // C4
#define CSLow() (PORTC &= ~0x10)
#define DCHigh() (PORTC |= 0x08) // C3
#define DCLow() (PORTC &= ~0x08)
#define ResetHigh() (PORTC |= 0x04) // C2
#define ResetLow() (PORTC &= ~0x04)
#define InitOLEDLines() { SetupDataOutput(); DDRC |= 0x7c; }
This is not the only thing needed to be changed; There are other small things like the delay function, but once I do change this I get an error. The Compiler tells me that the delay function has not been defined. I'm pretty sure I just left out an include in the file but I can't find out which one. Can someone help me find this out?
It would be great to see if anyone else get get this library to compile! If you get a chance try it out and see what you can do! Thanks!
Sun, 15 Jul 2012 07:27:02 +0000
What exactly did you change regarding the delay function? (as well as other changes?)
Jacob
Mon, 16 Jul 2012 14:43:02 +0000
The original library uses a It's own timer. It just has an algorithm to wait a number of Milli Seconds, I figure I could just do that with the delay function, but like I said before this causes an error and it tells me that the function can't be found.
There are also a couple more delays in the code and the library uses this:
asm("nop");
I know this is machine code to wait for once clock cycle but I don't know what the difference is between the two microprocessors.