PDA

View Full Version : Serin vs Serin2



The Master
- 17th October 2007, 18:10
Hi, which is the fastest to use, Serin or Serin2? This project needs speed rather than functionality so im wondering if its worth using serin this time

mackrackit
- 17th October 2007, 21:19
I do not think there is much of a speed difference between the two.

BrianT
- 18th October 2007, 12:40
The handbook says DEBUG is the smallest and fastest serial I/O command.

Why not try that?

HTH
Brian

Luciano
- 18th October 2007, 13:18
Hi,

These are software UARTS using the bit-banging technique.
The speed is the same because the speed is tied to the baud rate
you receive the data.

Best regards,

Luciano

The Master
- 18th October 2007, 16:16
ahh. that makes sense. im using 9600N at the moment. how do i know how high i can go? are there chip specific restrictions?

mackrackit
- 18th October 2007, 16:24
19200 according to the manual is the top end for SERIN/OUT2. You will need an OSC faster than 4MHz though.

Look at appendix A

The Master
- 18th October 2007, 16:29
oh. do you know the fastest for a chip using 4MHz?

mackrackit
- 18th October 2007, 16:44
At 4MHz the recommended is less than 9600. 9600 will work at 4MHz if all is stable.

There is some debate, but I do not like the internal OSC for serial, I use a crystal resonator (the ones with three pins, built in caps) seem to be very stable.

The Master
- 18th October 2007, 21:11
ahh, i cant go any higher then. i use an external oscillator anyway because thats the way i was shown how to do it. everything seems to be working fine now. i had a bug that looked like the serin command wasnt running fast enough but i turned out to be the wait() part.

the way ive solved it has created another question. the chips must wait for 250 and their own unique ID before doing something. that bit works fine but i want to be able to send a command that resets their ID no matter what it is.

the code im using now is
serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]

can i tell it to do something if it gets 251 and anything *aswell*? if not then i have a backup plan but i would rather do it that way

mackrackit
- 18th October 2007, 21:29
ahh,

the code im using now is
serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]

can i tell it to do something if it gets 251 and anything *aswell*? if not then i have a backup plan but i would rather do it that way

If I understand what you want the answer is yes. After the TIMEOUT for the 250 ends you could have it WAIT for 251.


serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]

serin2 porta.2,16468,2000,nocmd,[wait(251,?????),cmd,val]

serin2 porta.2,16468,2000,nocmd,[wait(252,?X?X?X),cmd,val]
Something like that :)
But this will eat up speed. Maybe decrease the TIMEOUT?

The Master
- 19th October 2007, 11:15
hmm, i see what thats doing. the timeout is designed to turn the outputs off if there is no data for 2 secs. the serin really does need to wait for 250,address all the time. just waiting for 250 then using an if-then statement to check the address takes enough time to cause problems.

i suppose the only way to do it is to send a long string from the PC that includes 250 and every address that i might use (about 1 to 40 should do)

mackrackit
- 19th October 2007, 12:56
Yes, the timeout will let the program move on if the wait character is not seem. With out the time out, the program could "wait" forever.

Depending on what you are doing you could decrease the timeout and check often, or use interrupts.

Or to maybe speed things up-- wait for "X" and write "address" value to a VAR(doing that already).

Then have some if / thens / else deciding what to do. This way the serial transmissions are short.
Kind of like you said but the long string is not needed.

Sorry if I am confusing things:)

The Master
- 19th October 2007, 16:50
that idea about putting the address into a variable and using if-then is how i had it in the first place. the trouble i had is that it would fire when the string gets sent out and try to read the first bunch of bytes. if the address didnt match it would return to serin but by that time the rest of the data has already passed.

there is only 1 string that gets sent out of the PC but that string has the values for all the chips in it