After programming picmicro assembly for more that a decade, I found the picaxe processors on the web. And they offer quite a bit of functionality that I had to craft myself in assembly before. So I ordered a 28X2 and build a breadboard, so see if this picaxe system is any good.
I am surprised. It really works well !! The only drawback I found so far is that none of the USB-serial convertors I had available works (so in the end I will have to purchase the picaxe one). Currently use a P4 PC which still has a single serial port.
Since I would like to have a seemless integration between IDE and serial port control, I was surprized to see there is a serrxd and sertxd set of commands. Bravo !! But (unless I misunderstood) I have not been able to make this seemless integration work.
I would like to achieve that the picaxe board goes into programming mode as soon as I close the terminal window in the IDE (so I can re-program the chip). I wrote a short routine to try this, where I wait for 1 second (time to be determined) for characters from serrxd, andthen check for programming mode, and back to serrxd. I use the timeout command for that.
Problem is .... it works in the simulator ... but it does not work on the actual picaxe chip. See attached code ....
What happens is that after the termination with a "q", the simulator jumps to the infinite do loop. But the actual 28X2 ends up (I am nort sure how) in the first do loop, the one with the serrxd command, and the timeouts continue after printing 2 rubbisch characters.
There must be some stack problem, that does not show in the simulator.
Can anybody show me where I go wrong ? I am not sure what happens with the timeout. Does the timout leave the stack in place (in other words, 1 level up in the do loop), or does it flush the stack ?
I am surprised. It really works well !! The only drawback I found so far is that none of the USB-serial convertors I had available works (so in the end I will have to purchase the picaxe one). Currently use a P4 PC which still has a single serial port.
Since I would like to have a seemless integration between IDE and serial port control, I was surprized to see there is a serrxd and sertxd set of commands. Bravo !! But (unless I misunderstood) I have not been able to make this seemless integration work.
I would like to achieve that the picaxe board goes into programming mode as soon as I close the terminal window in the IDE (so I can re-program the chip). I wrote a short routine to try this, where I wait for 1 second (time to be determined) for characters from serrxd, andthen check for programming mode, and back to serrxd. I use the timeout command for that.
Problem is .... it works in the simulator ... but it does not work on the actual picaxe chip. See attached code ....
Code:
'demonstrator to use programming serial port also for debugging
'and control.
'use PICAXE 28X2, running internally at 8MHz, therefore
'timing and frequencies are double.
'baudrate = 9600, timeouts are in 0.5mSec steps.
main:
'we scan for 1 second if a command is issued
'if not we print a "." and scan for another second
'in between we reconnect to allow interruption from
'the programmer.
do
retry_it: disconnect
serrxd [2000, timout],b0 '2000 = 1 sec, get char
reconnect
sertxd (#b0) 'reply char ascii code
loop until b0 = 113 'if q then quit
sertxd (13,10,"terminated")
do
loop until b0 = 0 'wait forever
'problem here ... for some reason
'we seem to fall back in the first do loop
end
timout:
'this timeout happens inside the do loop
'if we return to the do loop we do not cause a
'stack conflict (I hope).
reconnect 'needed ?
sertxd (".") 'activity dot
goto retry_it
There must be some stack problem, that does not show in the simulator.
Can anybody show me where I go wrong ? I am not sure what happens with the timeout. Does the timout leave the stack in place (in other words, 1 level up in the do loop), or does it flush the stack ?