PHOTO 5. Note the absence of the PmodRS232 and
presence of text on the display. This tells us that the
PIC32’s UART2 is driving the display module.
G1 has been given enough time to stabilize, we must
instruct the PIC32MX795F512L to transmit a 0x55. The
µOLED uses the 0x55 to determine the serial link baud
rate. Once it has zeroed in on the baud rate, it will
return an ACK (0x06) to the PIC32MX795F512L. At this
point, the µOLED-128-G1 is ready for work.
We’re going to need a timer to count down the
one second power-up delay. A timer may also come in
handy later if we find that we need to time other
events in the application. Rather than write a specific
timer routine for every unique event, we’ll implement
our timer using an interrupt. For now, a timer
granularity of 1 mS will suffice. Here’s the code we’ll
need to implement a 1 mS-per-tick timer:
OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_8,
ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
void __ISR(_TIMER_1_VECTOR, ipl2)
// clear the interrupt flag
if(++msecs1 == 1000)
msecs1 = 0;
Basically, we’re prescaling the incoming 80 MHz
clock signal to Timer1 by eight, which results in a
Timer1 tick of 10 MHz or 100 nS. On every 10,000
ticks (1 mS), we trigger an interrupt. The interrupt
handler clears the Timer1 interrupt flag and
accumulates the 1 mS ticks into seconds. Now that we
have an accurate way to measure time in seconds, we
can write the µOLED-128-G1 power-up delay code:
msecs1 = 0;
secs1 = 0;
LATFCLR = p5V_ENABLE;
while(secs1 < 2);
After clearing the 1 mS timer variables, we turn on
42 SERVO 02.2010
the TPS2041 which allows + 5.0 volts to flow to the
µOLED-128-G1, and then wait for one second to pass.
At this point, the µOLED-128-G1 should be ready to talk
to us. So, we transmit a 0x55 to it and wait for an
rxdata = 0;
msecs1 = 0;
while(msecs1 < 11);
rxdata = UARTGetDataByte(UART2A);
}while(rxdata != dmACK);
Once the 0x55 has been sent, we must give the
µOLED-128-G1 a bit of time to sort things out before
looking for a response. As you can see, we have put
the 1 mS timer to work on a 10 mS delay before
checking for an ACK from the µOLED-128-G1.
If the µOLED responds with an ACK, it has synced
up with UART2 and is ready to receive and process
commands. What do you think this code will do for us?
unsigned char cntr;
unsigned char cPutSERVO =
The results of executing the Place String of ASCII
Text (Formatted) command (0x73) can be seen in
Photo 5. The text to be displayed begins at column
0x00, row 0x00, and will be shown in an 8x12 font
(0x02). The displayed text color is white (0xFF,0xFF).
The ASCII string must be terminated with a 0x00.
Pretty cool, huh?
As the Carpenters would say, “We’ve Only Just
Begun.” I’ve got more µOLED stuff on tap. So,
we’ll scatter some more PIC32MX795F512L and
µOLED-128-G1 floobydust next month. SV
Fred Eady may be reached via email at firstname.lastname@example.org.
µOLED-128-G1 Display Module
EDTP Electronics, Inc.