My clock is at about 2Khz, and this code works well. But is there any way I can somehow condense the code?
Each character or function sent seems to want 7 bytes just to display it.
and 2K flash / 7 bytes a piece = 292 characters or LCD functions maximum. Then divide by 16 since my LCD only holds 16 characters = approximately 18 screens. This excludes code used for processing data.
P3.4 is attached to the Enable pin of the LCD and P3.5 is attached to the Instruction/Data pin at P3.4
These 2 instructions are being continuously repeated
write them at seperate place and use a call command to call them wheneevr required
If your data is predetermined store it in data memory and then use a loop to where you will move the data from the desired memory (pointed by a counter) to the P1 register
These 2 instructions are being continuously repeated
write them at seperate place and use a call command to call them wheneevr required
If your data is predetermined store it in data memory and then use a loop to where you will move the data from the desired memory (pointed by a counter) to the P1 register
I am not 8051 expert, but I don't think that placing these to instructions in sub-program is a good idea. It will require return stack place, and also Call/Return will take more time to proces. I would use Macro instead (if your IDE supports it).
Using macro's doesn't save any space, it simply inserts the macro code everytime it's used.
It's normal to write a subroutine to do such tasks as displaying a character on the LCD - which is how my PIC routines are done, something like this, to display a capital A on the LCD:
Code:
movlw 'A'
call LCD_Print
Where LCD_Print would be the name of the subroutine that displays the connets of W on the LCD. You should be able to do something similar on any processor?.
What I ment was, that it doesn't pay-off when only TWO instructions are placed in a sub-routine (And sometimes CALL instruction is as big as two normal instructions!).
Macros simplifie life, they don't save space tought...