This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

interrupts messin' with vsprintf ?

I have a 1ms fixed time interrupt scanning and debouncing a couple of switches, and a 1200 baud port receiving blocks of 17 chars 4 times a sec.
Asynchronously at 5 times/sec, I'm assembling an 8 character string to display on an 8 character DM display.
This code now uses a vsprintf statement, and occasionally the output string gets leftshifted one character in the buffer.
Surrounding the vsprintf call by EA=0 and EA=1 solves the problem, but the resulting delay to my fixed time interrupt messes up the switch scan.
Anybody have any clues on why vsprintf is getting upset, and how to get around it?
Thanks in advance.

Parents
  • "What happens if you all ways pass the vprintf statement a constant negative number?"
    I'll find out as soon as I get the new rcv code running. As I said earlier (actually, late last night!) I think I was blowing the stack, so I had to fix that problem first.

    "I am still interested in your Timer & Serial interupt priorities. The "using" statement refers to which register bank is associated with the ISR. Priority are set by you. You need to set bits in the IP (interrupt priority register). Sounds like they are at the same level."

    Understand. A code snippet will help here, I
    think:
    The serial port setup:
    /*------------------------------------------
    Setup serial port registers.
    ------------------------------------------*/
    SM0 = 0; SM1 = 1; /* serial port MODE 1 */
    SM2 = 0;
    REN = 1; /* enable serial receiver */

    TI = 0; /* clear transmit interrupt */
    RI = 0; /* clear receiver interrupt */

    ES = 1; /* enable serial interrupts */
    PS = 0; /* set serial interrupts to low priority */

    and now the fixed time interrupt :-
    TMOD &= ~0x0F; // clear timer 0 mode bits
    TMOD |= 0x01; // set 16-bit no prescale mode

    TL0 = (TIMER0_COUNT & 0x00FF);
    TH0 = (TIMER0_COUNT >> 8);

    PT0 = 1; // set high priority for timer 0
    ET0 = 1; // enable timer 0 interrupt
    TR0 = 1; // start timer 0

    (I omitted the EA=1, but it is in the code.)
    As you can see, the priority bits are taken care of.

    Point taken on the uncalled functions issue.
    I will certainly clean them up shortly. Right now I appear to have enough stack space, and I'm trying to get my new serial decoder working. I have a 17 byte fixed-format string coming in, and I have a checksum error for some reason.
    I'll report again as soon as it's working.
    Many thanks for the help, I appreciate it.

Reply
  • "What happens if you all ways pass the vprintf statement a constant negative number?"
    I'll find out as soon as I get the new rcv code running. As I said earlier (actually, late last night!) I think I was blowing the stack, so I had to fix that problem first.

    "I am still interested in your Timer & Serial interupt priorities. The "using" statement refers to which register bank is associated with the ISR. Priority are set by you. You need to set bits in the IP (interrupt priority register). Sounds like they are at the same level."

    Understand. A code snippet will help here, I
    think:
    The serial port setup:
    /*------------------------------------------
    Setup serial port registers.
    ------------------------------------------*/
    SM0 = 0; SM1 = 1; /* serial port MODE 1 */
    SM2 = 0;
    REN = 1; /* enable serial receiver */

    TI = 0; /* clear transmit interrupt */
    RI = 0; /* clear receiver interrupt */

    ES = 1; /* enable serial interrupts */
    PS = 0; /* set serial interrupts to low priority */

    and now the fixed time interrupt :-
    TMOD &= ~0x0F; // clear timer 0 mode bits
    TMOD |= 0x01; // set 16-bit no prescale mode

    TL0 = (TIMER0_COUNT & 0x00FF);
    TH0 = (TIMER0_COUNT >> 8);

    PT0 = 1; // set high priority for timer 0
    ET0 = 1; // enable timer 0 interrupt
    TR0 = 1; // start timer 0

    (I omitted the EA=1, but it is in the code.)
    As you can see, the priority bits are taken care of.

    Point taken on the uncalled functions issue.
    I will certainly clean them up shortly. Right now I appear to have enough stack space, and I'm trying to get my new serial decoder working. I have a 17 byte fixed-format string coming in, and I have a checksum error for some reason.
    I'll report again as soon as it's working.
    Many thanks for the help, I appreciate it.

Children
No data