Terminal Window issue with 14M2?

I have been playing around with the 14M2 storage variables and indirect addressing, and using the Terminal Window to observe the results. I'm having a weird issue that I hope someone can either confirm, or explain what I may be doing wrong. The easiest way to illustrate the issue is with a simple "HelloWorld" program:

Code:
#com 6
#picaxe 14M2
#no_data
#terminal 9600
    
main:
  setfreq m8
  pause 650
  sertxd ("Hello world!")
First of all, the pause statement seems to be necessary. If I remove it (or shorten it), the Terminal Window fails to display the Hello string at all. It could be that this is the first time I have ever tried to immediately send a string to the Terminal Window when a program first runs, so I don't know if a delay has always been required when the Terminal Window first starts up. That may well be, because I tried the same program on a 14M, and the delay was again necessary. In any case, including a delay is not a problem.

The real issue is that, whenever the Terminal Window first opens after a new program download to the 14M2, I get a single "garbage" character displayed in front of the "Hello world!" string. I accidentally discovered that this issue is connected to the "#no_data" directive. If it's removed, the garbage character disappears; if it's there, so's the garbage!

I also discovered that a 4k7 pull-down resistor on the 14M2 serout line solves the problem; the "#no_data" directive can be included, and the Terminal Window does not display the garbage character. That's an easy enough solution, but I would just like to understand what's going on. Is this really an issue with the 14M2, or am I missing something else that would explain what's happening?

Thanks...
Ron
 

hippy

Ex-Staff (retired)
The PICAXE will start running as soon as a download completes which is often quicker than the Terminal Window can open leading to data being lost if there isn't a PAUSE to start with.

I'm not sure about the garbage character; your code works and doesn't produce garbage for me, with or without #NO_DATA. You could try increasing / decreasing the PAUSE to see if that has an effect.

Which download cable are you using ?
 
Hippy - Thanks for the really fast reply!

I assumed as much about the pause, so it's not a problem.

I hadn't considered the download cable. I was using an FTDI 5V cable, but when I read your reply, I switched to the AXE027, and the problem was solved! I have absolutely no idea how a download cable could produce different results with and without "#no_data" but that's what seems to be happening. Thanks for clearing up the mystery!

Are you aware of any possible risk involved in adding the 4k7 pulldown on the serout line to make the FTDI cable function correctly?

Thanks again...
Ron
 

westaust55

Moderator
The time delay for the PE Terminal window to activate is not new and has been around as long as I recall with the PICAXE system.

Most of my programs using the SERTXD command start out as per the following example:
Code:
;
; -----[ Initialization ]--------------------------------------------------
;
Init:
	PAUSE 1000 			; this delay is to give the Programming Editor terminal Window time to establish
;
;
; -----[ Program Code ]----------------------------------------------------
;
Main:
 
Thanks Technical - That explains why my pulldown resistor solved the garbage character problem. I'll definitely keep it in my circuit.
 
Top