|
|
View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
Strange Hyperterminal output |
Posted: Mon Aug 31, 2009 5:41 am |
|
|
Head scratched:
Code: | #use rs232(baud=1200,xmit=PIN_C6,rcv=PIN_C7,bits=8,parity=N,stream=PC) |
Code: |
/*******************************************************************************
* 7bit communications
* Purpose: calcaultes even parity and transmits 7bits, E, 1stop via 8bit,N
* hardware.
*/
void seven_bit(int8 txbyte) {
int8 i;
int1 parity;
for (i=0;i<7;i++)
if (bit_test(txbyte,i)) parity++;
if (parity) bit_set(txbyte,7);
fputc(txbyte,PC);
} // 7bit
|
This works a treat when I set SIOW to use "1200-7-E No Handshaking", both directional comms to the PIC works flawless.
However when I set up hyper-terminal on the same PC same hardware, same PIC code I get gobbledegook on hyper-terminal.
Any ideas?
I add that another peripheral which is advertised as 1200-7-E works fine with both SIOW and Hyper-terminal set up the same way. So it's my PIC which is playing up! |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Mon Aug 31, 2009 5:53 am |
|
|
should be
Obviously siow is working differently to hyper-terminal!
Now I need to speed this code up. A quick search looks like a look-up table *may* be quicker? |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 31, 2009 7:30 am |
|
|
Quicker, but slightly bulkier:
Code: |
if (bit_test(txbyte,0)^bit_test(txbyte,1)^bit_test(txbyte,2) \
^bit_test(txbyte,3)^bit_test(txbyte,4)^bit_test(txbyte,5) \
^bit_test(txbyte,6)) bit_set(txbyte,7);
|
The individual bit tests, on a fixed bit number, each code to just four instructions (returning 0/1). The XOR's are one instruction each. The whole thing takes just 36 instruction times.
I think this may be almost as fast as the lookup table. The 'setup' for the lookup table, will probably be about 20 instructions, so by the time the value is returned, there won't be much in it, and the lookup table, will use 128 bytes for the table, plus the lookup code....
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 31, 2009 11:40 am |
|
|
You'll have to add a couple of instructions to this, since it just returns the parity. This will need to be tested, and put into bit seven, but I'd guess it'll still be easily under 15 instructions.
Better than a table solution, and very elegant.
Best Wishes |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Wed Sep 02, 2009 1:30 am |
|
|
I can't seem to get that assembler to compile for a PIC18, stumbles on the first line. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|