serial IO problem

wagp

New Member
I need to receive unsoliciated serial data from a Windows notebook using the background serial function (hsersetup, etc.) on a 40X2.
While waiting for the data to come in (hserinflag, hserptr), I also need to send unrelated serial data to a display attached to a different port on the 40X2.

It appears that the serial output to the display is interfering with the background serial receive from the Windows notebook.
I didn't see anything in the documentation that said I can't do this, but I can't make it work.

Any help would be appreciated.
 

nick12ab

Senior Member
The background "hardware" serial is interrupt driven and use of timing sensitive commands such as serout can cause problems with this.

If the serial display is a character LCD, then remove the serial backpack from the HD44780-compatible LCD module and connect the LCD module to the PICAXE-40X2 using the parallel interface. Use of the parallel interface will not interfere with the background serial.
 

westaust55

Moderator
See PICAXE Manual 2 Appendix 4 which covers some of the conflicts that can arrise.

In particular:
Internal Interrupt Driven Event Tasks
Task: . . . . . . . . . . . . . . Internal Interrupt: . . Command:
Background serial receive Serial interrupt . . . . . hsersetup
and:
The PICAXE functions above make use of internal event based interrupt tasks to process correctly. Internal event tasks temporarily ‘pause’ the main program
processing to process the task as and when it occurs. This is not normally noticed by the end user as the tasks are fully automated and very quickly processed.

However this system can cause potential issues on timing sensitive commands such as those using serial or one-wire communication. If the event were to occur
during the timing sensitive command, the command would become corrupt as the timing would be altered and hence incorrect data would be sent in/out of the
PICAXE chips. Therefore the following commands must temporarily disable all interrupts whilst processing:
Serial: serin, serout, serrxd, sertxd, debug
 

wagp

New Member
The background "hardware" serial is interrupt driven and use of timing sensitive commands such as serout can cause problems with this.

If the serial display is a character LCD, then remove the serial backpack from the HD44780-compatible LCD module and connect the LCD module to the PICAXE-40X2 using the parallel interface. Use of the parallel interface will not interfere with the background serial.

-----------------------------------
Thanks for the reply.

I'm a bit confused about the terminology "internal Interrupt" and what it means with the difficulty I'm having.

The problem I'm having is that something is stopping the background serial receive before it receives all of the characters .

The 40X2 program I'm writing is part of a system to monitor a heating system
The design incorporates three 40X2's and one 28X2 computers, along with 12 temperature sensors, 12 Optical Couplers, 12 tri colored LED's and four 5 volt relays.

The 40X2 program uses:
I2C, timer3, internal timer 0, hardware serial I/O and serial I/O functions.

Internal timer 0 is the only one for which I enable interrupts using the following instruction.
setintflags %10000000,%10000000

All of the other functions are "polled".
This 40X2 is the I2C "master" .
The serial I/O display I'm writing to is a Picaxe "AXE133 Serial OLED.
The Windows notebook I'm trying to interface with is running VB.net

Following are the setup instructions I'm using in this 40X2
hsersetup B2400_8,%00000111

tmr3setup %00110011

hi2csetup i2cmaster,I2Cslave,i2cslow,i2cbyte

symbol pulseRate = 49910
symbol interruptRate = 65534
settimer pulseRate
timer = interruptRate

In the "Interrupt" routine I count down several "counters" that represent various activities that I'm monitoring.

I'm not sure the meaning of what you're saying about the

.....background "hardware" serial is interrupt driven..............

Again, The problem I'm having is that something is stopping the background serial receive before it receives all of the characters .
 
Last edited:

srnet

Senior Member
The serial I/O display I'm writing to is a Picaxe "AXE133 Serial OLED.
If a serial character from the Windows notebook arrives the processor in the PICAXE needs to deal with the character from the notebook and store it in the background serial receive buffer. This takes a finite amount of time and will affect the timing of the serial commands to the AXE133, if they are in progress at the same time.
 

wagp

New Member
If a serial character from the Windows notebook arrives the processor in the PICAXE needs to deal with the character from the notebook and store it in the background serial receive buffer. This takes a finite amount of time and will affect the timing of the serial commands to the AXE133, if they are in progress at the same time.
------------
The problem I'm having is that something is stopping the hardware serial receive before all of the character from the Windows notebook are received.
 

nick12ab

Senior Member
You decided to post in that linked thread for some reason instead of here, that may cause confusion when others want to read this thread in the future.

The Serial display device I'm using is a Picaxe product AXE133 Serial OLED / Serial LCD.
(I actually have two, a 2 line and a 4 line)
I don't think it has a parallel interface capability.
Yes it does. Remove the small PCB from the LCD and you then have the paralllel interface

At one point I tried commenting out all of the serout commands to the displays and I still had the problem of incoming background serial receives stopping before all of the data was received. However, the program is large (3536 bytes out of 4096) and I may have missed something.

Do you think it possible my problem may be a conflict between the background serial I/O and the I2C bus?
I wouldn't have thought the i2c was the problem and it isn't listed as being a problem in PICAXE Manual 2 Appendix 4. However the timers are on the list so try removing the timers.
 

Goeytex

Senior Member
You might try using <hserout> to the Display instead of serout.

A test here showed no corrupted data in the background received data when using hserout to continuously send data ... while hsersetup receives background data every second or so.

When serout was used, the background received data was intermittently corrupted / missing.


Worth a try IMO.
 
Top