Shop OBEX P1 Docs P2 Docs Learn Events
UART and SIO on interupts? — Parallax Forums

UART and SIO on interupts?

CCraigCCraig Posts: 163
edited 2007-05-17 16:46 in General Discussion
Is it possible to run SIO on interupts? Do you used a flag to enable 'RX' mode. I can't find any examples. Did I miss it?


details:
I have a piggy backed GPS unit and Bean's SD data logger. The SX20 on the GPS (via Sio, single pin) sends a custom output string, waits a short time (15ms) for a command back, then goes on to log to the SD data logger if time to do so, process the command, get new data from the radio etc.

The host board (SX28 right now, moving to SX48 I think), has LCD/Keyboard and the Sio from the GPS/logger. The LCD/keybrd are running under UART isr (thanks JonnyMac and Bean). My thinking is that because the second UART is mostly in the RX mode getting data from the GPS/logger and must send a command right after recieving the data burst, I can use a flag to set it to TX mode so the RX code won't receive it.

Will that work? I don't see why not, but "Newbie ALERT". Even more so with isr's. Still, this has been a very good 'first' isr program.

Thanks for Your Support, Chris

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-05-17 16:20
    Funny, I'm just writing my July article for Nuts & Volts that shows how to do that. I do use a bit of a cheat: in a perfect world the serial line would only be pulled low by the SX for transmitting a "1" bit (assuming true mode) and left to the pull-up for a "0" bit, but this creates a lot of code trickery in the ISR that I don't want to be bothered with. Since only one device should be talking at a time, I just use a 220-ohm resistor inline with the serial pin to prevent pin death in the event of an electrical conflict.

    Since this is a slave device and does more listening than talking the program does check to make sure it's not in the middle of transmitting a byte before configuring the Sio line as an input so that it can receive one.
  • CCraigCCraig Posts: 163
    edited 2007-05-17 16:46
    Thanks Jon,

    Man, you're going to have more code in my project than me!

    Thank you very much, Chris
Sign In or Register to comment.