Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT to PC using sxwiz compiler — Parallax Forums

SEROUT to PC using sxwiz compiler

stefstef Posts: 173
edited 2006-11-07 12:02 in General Discussion
Hi

Can anybody point me to de good direktion. I'm a bit confused by setting up a communication from an sx28 to a pc (serial connection.) I attached rb.o by a resistor 33 k to the pint 2 of the commport and pin 5 (gnd i think) to the vss .
I declared dimbit tx=RB.0
and
level rb=$ff

I use in sxwiz (basic compiler) the SEROUT TX,"abcd",3

I'm running on the internal 4 Mhz clock.

Now the confusing bit. What is the baudrate at tis point. The 3 is for 9600 baut at 50 Mhz I think.

How to set it up at 4 Mhz.

The rest of the program is running fine.


Thanks for any help


Post Edited By Moderator (Bean (Hitt Consulting)) : 11/6/2006 11:17:40 PM GMT

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-06 22:31
    Read 'understanding serial I/O' in the sxwiz help.
    Scroll down to Using Interrupt Driven SIO Routines
    You need to set
    TIMEBASE 10.417···' 9600 baud bit-time'
    change the timebase value for other baudrates.
    For non-interrupt use, I think the sxwiz compiler
    automatically adjusts for the given clock frequency.

    regards peter
  • stefstef Posts: 173
    edited 2006-11-06 22:43
    Hi peter

    I read the section on serial I/O but wen I use timebase 10.417 and try to compile the compiler is generating an error. "timebase is out of range. Use higher frequency clock". Des that maen that At 4Mhz I can't use 9600 baute???

    If i step over to 50 Mhz I need to use an external cristal??



    stef
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-07 00:05
    Apparently sxwiz does not support 9600 baud on the interrupt driven serial I/O
    at 4MHz. You could use a 20MHz or 50MHz resonator (which is easier than a crystal).
    For non-interrupt serial I/O, 9600 baud may be supported at 4MHz.

    regards peter
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-11-07 08:34
    Hi Stef,

    using the internal 4 MHz clock for serial communications applications is not a good idea because this internal clock is not very precise, and not stable. So even if you manage to have SXWIZ generate code for 9600 Baud, the communications would not work reliably. Therefore, you better use an external resonator as Peter suggested.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • stefstef Posts: 173
    edited 2006-11-07 11:41
    Hi

    Thanks to the person that filled in my topic header. It was late for me laste night and I forgot to fill it in.

    Thanks Guenther and peter for the help. I swapt my project to use an external resonator.

    Now I can compile and run it but I get the wrong data true the serial. Not to panic. It will·be some stupid thing i do wrong so let me lern a bit by searching for the problem. Perhaps you see that I 'm the same guy from a few days ago at the javeline forum that wants to read WIEGAND. I swaped over to sx but now I need to lurn a bit. I'm not used to this PIC.

    Nevertheless, it is already working for reading data. I have it on my desk with a liddle led flashing when it is getting valid data.

    Thanks again fur the useful information.

    I hope to post it when it is finisched so I can help others with it but that I want to do when it is finisched.I need to implement some other stuff also. Reading not only 26 bit wiegand but also sending wiegand out, reading as high as 50 bit, autodetekt bitlengt, sitecode place, issuecode place, cardnumber pllace, ecc...

    Also I hope to implement an other protocol called clock and data. Ofthen used by magnetic cardreaders. I also like to implement reading and sending that protocol. Any sugestion????

    As you can imagin I worke for a security integrater company.

    Stef
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-07 12:02
    Here is a great source for info on card technology
    http://www.epanorama.net/links/smartcards.html

    Here is a document describing the clock and data protocol
    http://www.epanorama.net/pdf_redirect.php?url=http://www.hidcorp.com/espanol/pdfs/appnote_2.pdf

    regards peter


    Post Edited (Peter Verkaik) : 11/7/2006 12:10:35 PM GMT
Sign In or Register to comment.