Shop OBEX P1 Docs P2 Docs Learn Events
Delay on SX28 — Parallax Forums

Delay on SX28

John WhitfieldJohn Whitfield Posts: 42
edited 2005-06-03 17:50 in General Discussion
Does anyone have any code that will delay the entire MainLoop of my program without delaying the UARTs in my code attached to the below thread about the Dual UART problems. What I mean is a simple delay for like one to ten seconds or maybe longer after each time the UART takes in and sends out data.

Thanks,
-John Whitfield

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-06-03 07:22
    John,

    at www.sxlist.com/techref/piclist/codegen/delay.htm you find a delay code generator. You specify the clock frequency and required delay time, and it returns the source code to generate that delay.

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

    G
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-06-03 14:56
    If your UARTs are implemented as Virtual Peripherals (RTCC triggered ISR code), you can use the utility provided by Guenther and just insert it into your mainloop. The Virtual Peripheral UARTs will continue to run even when the maincode is delaying.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-06-03 17:50
    Paul,

    good point - I forgot to mention that.

    BTW: Actually the delay time will be longer than calculated because the ISR code "steals" execution cycles whenever it is invoked, For a longer deleay time, this does not matter in most cases unless you need a precisely timed delay. In this case, it makes sense to implement a Timer Virtual Peripheral which can be combined with the UART VP in the ISR.

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

    G
Sign In or Register to comment.