serrxd on 08m2+

Bellgrove

Member
I'm trying to send three bytes from a PC running python to PICAXE using serrxd.
The python line is s.write(bytearray([0,1,2]))
PICAXE line is serrxd[150,PC_timeout_trap],b5,b6,b7
It works fine on an 18M2+, but on an 08M2+ the first two bytes are received OK, but the third byte is unreliable (sometimes right, sometimes not).
I've tried using another 08M2+ with the same result.
Any suggestions for a fix?
Jack Hale
 
It will help to have a short delay between each byte being transmitted to the PICAXE. You may find that setting the PC's serial port to have 2 stop bits may provide enough delay between bytes/characters. Alternatively, running the PICAXE at 32MHz may help too.
 
Hi,

I'm quite surprised that SERRXD works at all because it uses quite a high baud rate relative to the Instruction Clock frequency. For this reason I don't believe that increasing SETFREQ would help, but increasing the (transmitted) STOP to 2 bits, and perhaps adding a Parity bit (which the PICaxe will ignore) may well give the addition timing margin that is needed.

However, despite (generic) conflicting statements elsewhere, with an 08M2 it is possible to use also SERIN and even HSERIN instructions on the Serial/Programming Input pin (C.5). SERIN with a lower baud rate, or a higher Clock frequency, should give plenty of additional margin if needed. However, HSERIN, using the Alternate Pin Function Control SFR (APFCON), is a real "Can Of Worms", but it is possible to receive fully concatonated bytes at 19200 baud with an M2, interrupt driven if desired, to almost compete with the X2's Background Receive mode (of course with a buffer/RAM up to only 100 bytes, if an 08M2). Details HERE and HERE.

Cheers, Alan.
 
Thanks for your full response Alan.
I've gone over to using the 18M2+ which I've always found to work reliably with SERRDX. A few extra I/O pins will always come in useful.
I wonder why it works when 08M2+ does not. Does it use a higher frequency instruction clock?
Regards... Jack
 
Hi,

Sorry, I've never measured an 18M2 because I prefer the consistent Supply/Programming pinouts of the other M2s. However, the 08M2 is significantly faster than the other M2s (at least with some instructions) because the 14/20 pin chips have their pins "remapped" relative to their internal ports. Also the 08M2 may be faster because it has less complex hardware to control. The only area where I know it may be slower is in executing subroutines, because the other chips are said to have an additional "lookup table", and a syntax check shows they sometimes can have a smaller program size than the 08M2.

AFAIK all the (M2) chips have identical instruction cycle speeds, but obviously the specific Compiler/Interpreter code must be somewhat different. However, IMHO the differences are likely to be mainly dependent on the specific instructions being executed between the SERRXDs, and of course exactly how long are the gaps between the received characters?

Cheers, Alan.
 
Back
Top