4x20 OLED problems

thunderace7

New Member
Hi. I'm having trouble with interfacing a 4x20 oled with my picaxe 40x2. On power up I get the startup screen but then it just goes to rubbish.
I think it's a problem with the clock speed but I'm not sure. I have reduced the program to just clear the screen but even that doesn't work. The program is as follows :

#picaxe 40x2
setfreq em64
pause 4000
let dirsB=%11111111
let pinsB=%00000000
serout B.7,N2400, (254,1)
stop

Can anyone see what I'm doing wrong?

Thanks
 
Last edited by a moderator:

nick12ab

Senior Member
Yes it is a clock speed issue. The serout command does not support 2400 baud above 16MHz.

You must change to a lower clock speed, use hardware serial instead (which can do 2400 baud at 64MHz), or better still, use the parallel interface if possible (though that requires more work).
 

Goeytex

Senior Member
You must tell serout the clock speed. e.g, Serout B.7,N2400_16 (Data,Data).

However, Serout B.7,N2400_64 is not valid due to the high 64Mhz clock speed.
The highest clock speed that serout "2400" supports is 16 Mhz. (See Manual 2 Page 208)

If you must operate at 64Mhz and use 2400 baud, then you will need to use Hserout on C.6 (PIN 25)

Try This:

Code:
#picaxe 40x2
setfreq em64
Hsersetup, B2400_64, %10010   [COLOR="#008000"]'Hserout = Inverted, Hserin (C.7) is normal I/O   [/COLOR]

pause 4000
let dirsB=%11111111
let pinsB=%00000000
Hserout 0, (254,1)
stop
 
Last edited:

thunderace7

New Member
Thank you both for your replies. I have a 16Mhz resonator wired to the board. Can I switch to an internal frequency without removing the external resonator?
 

westaust55

Moderator
You could just set the clock speed to 16Mhz to test your display with em16 rather than em64
If the external resonator is 16 MHz then irrespective of the "EMxx" setting the clock frequency will be 4 x resonator = 64 MHz.
The "EMxx" only helps the firmware identify some timing requirements.
 

hippy

Technical Support
Staff member
Thank you both for your replies. I have a 16Mhz resonator wired to the board. Can I switch to an internal frequency without removing the external resonator?
Yes. Issue a SETFREQ M8, send your SEROUT data using N2400 or N2400_8, then SETFREQ EM64.
 

techElder

Well-known member
Now there's a conflict. It can't be both ways. Is the PICAXE going to be running at 8MHz or locked into 64MHz with the external resonator?

I read (or was told or assumed) that the frequency was fixed by the external resonator (on the 40X2) being connected.
 

Technical

Technical Support
Staff member
In internal resonator modes (like m8) you choose what you want the clock speed to be. You can still use this even if an external resonator is connected.
In external modes (em64) the clock speed will always be 4x the value of the external resonator. So even if you incorrectly type em40 it will still run at 64MHz (if a 16MHz resonator is connected).
 

techElder

Well-known member
So my question is then, "What resonator is being used? Internal or External?"

EDIT: I should have put my reason for being interested. My 40X2 application will need certification because it is timing something. I need to decide what part of the application I will not be certifying.
 
Last edited:

Technical

Technical Support
Staff member
m = internal, em = external.
So after a 'setfreq m8' it is using the internal resonator, after 'setfreq em64' it is using the external resonator. You can swap between internal and external as you please.
 

thunderace7

New Member
Thanks to everyone for the discussion, I think I understand it now. There is a lot of information about using the oled display scattered around the documentation but it seems that nowhere is it complete.
 
Top