BaiscChip hangs in SEROUT or bbTXD

Questions on UARTs, and serial communication
ronr
Posts: 22
Joined: Tue Nov 05, 2013 8:17 pm

BaiscChip hangs in SEROUT or bbTXD

Post by ronr »

I have used SEROUT on a pin other than IO(0) or IO(1) with the ArmitePro with NO problems.
Now using the BasicChip, calling SEROUT may cause the BasicChip to just stop, when I make repeated calls to SEROUT.
Calling SEROUT often (just once a second) will cause a hang-up within a few seconds. Even after several seconds wait, the next call to SEROUT may hang.
I have used bbTXD instead and find the same problem.
I am using IO(41) as the TXD pin at 9600 baud. I have reduced the program, for testing, to do nothing but call SEROUT with a 3-character text string, in response to my commands on BasicChip's hardware serial, on IO(0) and IO(1).

What could be causing this problem? Something I'm doing wrong?
Thanks for any advice.



olzeke51
Posts: 394
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: BaiscChip hangs in SEROUT or bbTXD

Post by olzeke51 »

could you post your basic 3 character code ??
Thanx, Gary
'
are you getting the first one or two transmissions?
is it the straight BasicChip or is it on one of the boards.
TNX

ronr
Posts: 22
Joined: Tue Nov 05, 2013 8:17 pm

Re: BaiscChip hangs in SEROUT or bbTXD

Post by ronr »

I am just sending the 3-character string /HI
The first one or two or three transmissions go okay, then the next serout causes a hang-up. It happens for sure if I serout rapidly, like 2 or 3 per second. I use the same simple code in the ArmitePro (except for differences for the specific hardware) and it transmits as fast as I can command it.

basicchip
Posts: 1039
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: BaiscChip hangs in SEROUT or bbTXD

Post by basicchip »

SERIAL.bas was written before the change of TIMER to use SysTick.

SysTick relies on interrupts being enabled and if they are disabled eventually you will hang up calling TIMER as it won't be able to increment across the 24 bit boundary (65 msec).

SERIAL.bas needs to be rewritten using WAITMICRO.

ronr
Posts: 22
Joined: Tue Nov 05, 2013 8:17 pm

Re: BaiscChip hangs in SEROUT or bbTXD

Post by ronr »

Thank you, sir, for that answer, which seems to give a real good reason for my problem. Is there anything I can do now in software to fix the problem for the BasicChip? It seems that right now my only solution is to design my new board around the ArmPro Board, which I have tested to work well.

basicchip
Posts: 1039
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: BaiscChip hangs in SEROUT or bbTXD

Post by basicchip »

Give this one a try, all it does is change the wait loops inside the interrupt(0)/(1) to calls to waitmicro. To work on the ARMmite it would need a definition of waitmicro, but it should work on the newer Cortex parts.

I don't have time to test it now. If it works for you I'll put it in the next release.
SERIAL.bas
(3.89 KiB) Downloaded 549 times

ronr
Posts: 22
Joined: Tue Nov 05, 2013 8:17 pm

Re: BaiscChip hangs in SEROUT or bbTXD

Post by ronr »

I have tried that new Serial.bas and it works perfectly! Even looping in continual SEROUT calls for several seconds doesn't bother the BasicChip anymore. Thank you so much for providing this fix so quickly!

ronr
Posts: 22
Joined: Tue Nov 05, 2013 8:17 pm

Re: BaiscChip hangs in SEROUT or bbTXD

Post by ronr »

This may not be right place to post this but....I find a similar hang-up problem with repeated calls to PULSOUT and PULSIN.
This takes a bit longer to hang-up..like fifteen minutes of calling PULSOUT/PULSIN at about 7 to 10 times a second. (This is operating a Parallax "Ping" sensor.)
I have not yet done tests to see at what rate it might not hang-up.

Is there a similar timing problem that may be corrected with a newer PULSE.bas?
Thank you for your attention.

olzeke51
Posts: 394
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: BaiscChip hangs in SEROUT or bbTXD

Post by olzeke51 »

as Basicchip mentioned above ::
SERIAL.bas was written before the change of TIMER to use SysTick.

SysTick relies on interrupts being enabled and if they are disabled eventually you will hang up calling TIMER as it won't be able to increment across the 24 bit boundary (65 msec).

SERIAL.bas needs to be rewritten using WAITMICRO.
''
'
any of the routines.BAS that disable interrupts INTERRUPT(0/1)are going to have issues.
You will need to rewrite the routine - a) removing the INTERRUPT() and b) use the WAITMICRO() for timing.
this is a community effort; especially now as hardware makes many advances
'
compare the old Serial.BAS to the one Basicchip just posted for ideas.
HTH, Gary

basicchip
Posts: 1039
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: BaiscChip hangs in SEROUT or bbTXD

Post by basicchip »

PULSE.bas is really meant for people porting from BASIC stamps, it is much better to write your own routines using TIMER for long times or WAITMICRO for short times on the newer parts.

Again turning off interrupts, disables TIMER from counting across 65 msec boundaries. You can re-enable it by-

Code: Select all

	INTERRUPT(0)	
	#ifdef ST_CTRL
	ST_CTRL OR= 2		' re-enable SysTick interrupt
	#endif
This won't be as accurate as possible, but still far more accurate than a BASIC stamp.

So here is PULSE.bas without testing
PULSE.bas
(3.89 KiB) Downloaded 506 times

Post Reply