Page 1 of 1

Serial data issue

Posted: Sat Aug 14, 2010 6:45 pm
by Baldrick
Does anybody know off the top what is sent to a serial port when 2 side by side keys are pressed simultaneously?
I ask as I have been writing a program for my micro controller project & have set the micro up to just spit it's firmware version back to any user trying to access via a terminal such as hyper terminal. It is all working lightning quick, with the exception that if you manage to press in between 2 keys giving a simultaneous keypress. This is somehow managing to completely lock up my micro, forcing a reboot to get it running again.
( Not really a problem so long as people use my purpose built program for set up, but still a little bit annoying that this is happening & if I can't work out why, I will just probably restrict terminals to a single character such as 'v' to get anything back from my controller, with all other keys just simply clearing the micro's Rx buffer.) :)

Re: Serial data issue

Posted: Sat Aug 14, 2010 7:15 pm
by Joakim Christiansen
If I had the source code for the micro controller I could try to see if there is any reason for it hanging. I've also played around similar stuff, but I made my own "terminal" program using PB's console stuff.

Re: Serial data issue

Posted: Sun Aug 15, 2010 4:27 am
by Baldrick
Thanks for the offer Joakim, but I really dont want to release source for this as it is my little commercial venture.
Fwiw, I too have written my own PB Windows based GUI console for all end user programming to the eeprom. It works along the lines of using an ascii digit as byte 0, location to read as byte 1, value to write as byte 2 & byte 3 as a padding / comparison check being sent from the computer.
The micro when it sees say ascii 3,5,200,3 will then write a value of 200 in eeprom location 5, read the new value from the eeprom & return ascii 3,5,200,3 so the computer knows to move onto the next location, etc.
Works really well & is giving me around 12 / 14ms complete round trip time per location meaning I am able to write a complete 255 byte eeprom in around 3.5 seconds. ( I am converting all 0 values to ascii 255 to avoid the Null termination issue which means I am only unable to access byte 255 of the micro memory which suits me very nicely. )
I deliberately set the micro up to send back a version string if 1st Rx'd byte is greater than ascii 7 with the idea this would allow people to try hyperterminal on it, but give up after a few minutes as all they get is the same version string sent back to them. :) This also works really really well & you can literally drag your hand over the keyboard while using a terminal & the returns just keep coming. It just fails if you simply press 2 keys simultaneously side by side. e.g. press between the q & w keys or say the g & h keys so they both physically get pressed at the same time. :? ...
I might set up 2 machines linked via hyperterminal to see what happens with them when this 2key scenario is done I think.

Re: Serial data issue

Posted: Sun Aug 15, 2010 11:22 am
by Pupil
Have you ruled out overflow for Rx/Tx buffer and such? I would suggest that you for testing purposes create a simple echo program in the micro controller that just sends back everything that it receives. By doing this you'll be able to see what's being sent when two keys are pressed simultaneously.
I've read through your posts and couldn't find if you said which controller you used. Whichever controller you use it's always a good idea to see if you can find an errata for the chip. Quite often you'll have to make some workarounds. I've worked some with Microchips PIC-controllers and often found that the build in UARTS have issues with handling interrupts for the Tx and the Rx buffer.

Re: Serial data issue

Posted: Sun Aug 15, 2010 2:01 pm
by Baldrick
Thanks very much for your info Pupil, it gave some good places to go hunting.
I think I have now fixed the problem which seems to have been a compiler issue where I was having a few problems with the way it was allocating my variables in memory. I had set 1 variable to an absolute address to overcome being unable to read some bitvars due to the compiler putting them where I was unable to look at debugged results. Removing the absolute address & allowing the compiler to assign for me seems to have fixed this hang fault. ( I am just unable to explain as to why...... :? )

Just so you know, I am using a HiTech PicC compiler through the MPLab IDE & working with a Pic 16F876A chip.