Shop OBEX P1 Docs P2 Docs Learn Events
SX/B, interrupts and serial output - Page 2 — Parallax Forums

SX/B, interrupts and serial output

2»

Comments

  • RsadeikaRsadeika Posts: 3,839
    edited 2008-07-03 20:58
    I hope that JonnyMac goes into some painfull detail in his new book, which should be available this month, I think, about how to work the numbers for serial, and the isr. This thread, and the detail that was involved in figuring out the isr, is why I went over to the Propeller. Somebody should come up with a step by step, highly detailed account of how to figure out the numbers for this stuff. Maybe then I might get interested in the SX chip again. Hopefully all the answers are in the new book, it should be a great read.

    Ray
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-03 21:09
    I will be delivering materials this month -- we gotta give the good folks at Parallax time to do all the printing stuff. I do go into some detail on background serial since that seems to be a Holy Grail type thing with many Stamp users. Trust me, none of this is brain surgery (and, personally, I find the SX way easier to deal with than the Propeller). Keep in mind that no one person can teach you everything, so I hope that you'll use Practical SX/B for its intended purpose: to get you going with real code and encourage you to experiment and explore; that's how most of us have learned what we know.
  • DosManDanDosManDan Posts: 179
    edited 2008-07-04 06:24
    I know I definitely learned something from all of this. I love the SX and have been using it for a year now but have avoided the interrupt because I could always get around it. That was great until I started the current project, and I have to use interrupts. I've read all of the back issues of N&V and the SX/B materials, the SX book by Gunther, and was really getting confused as to what was important in calculating the interrupt speed.

    Was it the speed of the resonator, the baud speed, the number of times I wanted to sample...? After becomming totally confused, I decided to start this thread.

    Jon has really shown his dedication to this forum by continually answering questions for everyone. Difficult as well as easy questions are answered in a friendly manner. I would have come to a grinding hault without his help this time.

    Saying "thanks" never seems to convey how grateful I really am, but I don't know what else to say.

    Thanks Jon!
    Dan
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-07-04 09:32
    Dan,
    Here is a little excel sheet to calculate uart divisor values
    for baudrates 1200 to 230400 given clockfrequency, intperiod and isr threads.
    It also calculates the isr rate.
    The divisor values show which baudrates are possible given
    the clockfrequency, intperiod and threads.
    Just set the green colored fields.

    regards peter
  • DosManDanDosManDan Posts: 179
    edited 2008-07-04 09:46
    Thanks!

    I have the code working, but the clock time is wrong, since I'm using the faster 50MHz resonator. I'll give your spreadsheet a shot.

    Update:
    The program is up and working!!!! The timing issue was due to an error I made. Found it, fixed it. Just need to add buttons and I'm there.

    Thank you to everyone who assisted(especially Jon),

    Dan

    Post Edited (DosManDan) : 7/4/2008 10:40:28 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-07-04 10:50
    Dan,
    Attached is Jon's program, added with a few constants to calculate
    the·baudconstants and timerconstant automatically.

    Just set the FREQ directive to your frequency and set the ISRRATE to an appropiate value.
    Don't forget to set this value also as INTERRUPT parameter.

    I have set it for FREQ = 50_000_000 and ISRRATE = 230400

    regards peter
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-04 16:23
    Dan,

    I'm glad everything is working. The key, now, is to play. Experiment with these concepts when you're not under pressure to have a project completed, that's how you'll really get to understand to use these techniques in a variety of applications. Though many of us may approach a problem differently, we probably have spent a lot of time experimenting with concepts and strategies before applying them. My acting teacher loves to use Michael Jordan as an example; MJ was so good in the game because he spent so much time outside the game practicing his craft. It's good advice for us all.

    Happy 4th!

    Jon
  • DosManDanDosManDan Posts: 179
    edited 2008-07-05 01:46
    Thank you for the advice, I'm going to really experiment when everything is done.

    Peter, thank you too. I'll take a look at your code tonight after the fireworks show.

    Take care and have a happy 4th everyone,
    Dan
  • YendorYendor Posts: 288
    edited 2008-07-24 16:52
    Jon,

    Just curious, what kind of application did you attack that·required·a TX Buffer to where the Tx data being generated is·faster than the baud rate?

    Man, I bet that was tough to catch, and thanks for sharing!

    Your favorite pest,
    Rodney
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-24 18:25
    I added the buffer to the TX side so that the program could get on with what it was doing while the characters were being transmitted -- no need in waiting around.
Sign In or Register to comment.