40x2 clocked at 32Mhz - Is serout possible

darosu

New Member
Dear all knowledgable people out there..

I cannont interface with my Serial GLCD display if i clock my 40X2 picaxe to 32mhz (8Mhz external crystal) as there are no baudrate options for 32, only 4,8 or 16.

I am looking for 2400 baud, and the lowest i can trick it to is 4800 by telling it I have 1200 baud and a 4 mhz cyrstal.

Is there a work around, or potentailly a compiler update that allows 2400_32 as a software serial baud rate?

Thanks

Darosu
 

hippy

Technical Support
Staff member
SERIN and SEROUT only have four baud rate options and these scale with increases in clock speed ...
Code:
4MHz   8MHz   16MHz   32MHz   64MHz

600  
1200   1200
2400   2400    2400  
4800   4800    4800    4800
       9600    9600    9600    9600
              19200   19200   19200
                      38400   38400
                              76800
It's just not physically possible to use 2400_32 without adding more baud rate options to the firmware, but there are a number of solutions ...

* Use HSEROUT which will support B2400_32

* Fit a 4MHz crystal and operate at 16MHz using N2400_16

* Run at 32MHz but drop down to internal 8MHz when using SEROUT with N2400_8

It's also worth noting that SERTXD and SERRXD operate at the fasted baud rate for the operating speed, 9600 at 8MHz, 76800 at 64MHz etc. 76800 isn't a so-called 'standard baud rate' which all OS's, applications and physical serial ports recognise. It is usable for PICAXE to PICAXE comms and the AXE027 supports that baud rate in all testing I have done.
 
Last edited:

darosu

New Member
Thanks Hippy,

I feared that was the case.

I think my only option is to opt for a general clock speed of 16Mhz then.

I don;t think i can temporarilly drop the speed when send software serial as that would upset my hardware serial that would be running constantly in the background...

Best go by a 4Mhz external crystal thingymabob then i guess...

Darosu
 

hippy

Technical Support
Staff member
Another option, not as cheap as a 4MHz resonator, and maybe not a solution in this particular case, is to add another X1/X2 as a baud rate converter.

That can take the SEROUT from the sender via background HSERIN and churn it out at 2400 baud. You can use SEROUT in the sender at a high baud rate which reduces overhead and allows 32MHz or faster operation, and if the converter can track the packet format for the GLCD it can generate the necessary pauses so none are needed in the main program. The only thing to avoid is overflowing the serial buffer in scratchpad.

As the converter would have a single task, and a relatively straight forward one, although a more complicated system with two PICAXE's, it might not actually be much more complicated as a whole.
 

womai

Senior Member
Actually at 32 MHz the Picaxe should run fast enough to implement bit-banged serial out, i.e. toggle the output pin manually with suitable pauses inbetween. A scope will help a lot getting the output timing right.

Another - easier - option would be to switch to the internal resonator whenever you need to do a serout:

setfreq m8
serout .... ' now you CAN use 2400 baud
setfreq em32
 

darosu

New Member
Thanks guys,

I think this has to be about one of the best forums in the world! Ask a question and recieve answers the same day that are actually useful! It ashame all forums aren;t like this one!

So I will progress with running at 16Mhz and using the software serial out at 2400_16

Hippy: I like your idea of using a second X1 or X2 to 'translate the baud rates' to my slow GLCD module. This would allow me to leave my main chip at 32Mhz and to check my inputs as often as i fancied (very often).

If i did this and i am using the hardware serial-in to recieve background serial data, can i send hardware serial data out at the same time? or is the hardware only capable of one of the other?

Thanks again guys,

darosu
 

manie

Senior Member
A question that fits here also is: What maximum baud rate does the FRM010 chip handle and how would one accomplish comms with it ?
 

hippy

Technical Support
Staff member
If i did this and i am using the hardware serial-in to recieve background serial data, can i send hardware serial data out at the same time? or is the hardware only capable of one of the other?
No reason I can see that HSEROUT wouldn't work with background HSERIN and SEROUT / SERTXD as well. You'd be tied to having HSEROUT the same baud rate as HSERIN but that should be the only limitation.
 
Top