GLCD 12864 - Busy check - Unrolled code

Thread Starter


Joined Jan 6, 2004
I am about to start writing code in Assembler (PIC 18F) to handle the basics of a GLCD (definitely trying to reinvent the wheel, which, by the way, I found nowhere up to now).

Two basic questions:

a) Given the need to check the busy flag, is it better to do it immedately after writing and leave with the "homework done" or leave it unchecked and do it prior writing the next time? (Second option gives the chance to find the BUSY flag already low reducing the waiting time. Am I right?)

b) For the different basic routines is it better to write them totally unrolled or make them compact using as much as possible CALL / BRA instructions?


Joined Oct 14, 2005
For the first question, I prefer to do the checking prior to writing or doing other tasks. The first reason is like you say, it reduces the waiting time slightly. The second is, it is reassuring to know for sure that the device is ready. I/someone might insert some code somewhere without checking for busy status and break the code.

It depends on how compact you want it to be. You are not really limited by program memory size, are you? Compact code are more difficult to debug, trace and maintain. There is no need to unroll everything or make them super compact. Somewhere in between, there is a balance between code size, execution speed and ease of maintenance/readability.