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

array inside interrupt function

I having trouble sending data out under interrupts from a buffer.

The buffer was declared in xdata and i have a counter that is used to index into it.

So when an interrupt occurs, the data is loaded into my SPI tx buffer, ie
SPIBUF = txbuffer[index];
index++;

All i seem to get is all zero's but if i use the index to send data i get something.
ie SPIBUF = index;

David

Parents
  • From that assembly listing, everything looks exactly correct.

    My guess is that your memory doesn't work correctly (or as you expect).


    552: txbuffer[4] = 0x44;
    c:0x1938 A3 INC DPTR;
    c:0x1939 7444 MOV A,#QueueSize(0x44)
    c:0x193b F0 MOVX @DPTR,A
    553: P1 = txbuffer[0];


    This is all exactly correct. The debugger disassembles your code. The disassembly EXACTLY matches the listing that you provided. Which, I might add, is exactly what it should be.

    This kinda reminds me of a project I looked at were the programmer duplicated every move into R0. For example,

       mov a, #12h
       mov r0, a
       mov r0, a
    
       mov a, @r0
    

    When asked why the double move into r0, he responded, "Because the first one didn't take."

    My question was, "If the first mov r0 didn't take, how do you know that the second one always would?"

    Jon

Reply
  • From that assembly listing, everything looks exactly correct.

    My guess is that your memory doesn't work correctly (or as you expect).


    552: txbuffer[4] = 0x44;
    c:0x1938 A3 INC DPTR;
    c:0x1939 7444 MOV A,#QueueSize(0x44)
    c:0x193b F0 MOVX @DPTR,A
    553: P1 = txbuffer[0];


    This is all exactly correct. The debugger disassembles your code. The disassembly EXACTLY matches the listing that you provided. Which, I might add, is exactly what it should be.

    This kinda reminds me of a project I looked at were the programmer duplicated every move into R0. For example,

       mov a, #12h
       mov r0, a
       mov r0, a
    
       mov a, @r0
    

    When asked why the double move into r0, he responded, "Because the first one didn't take."

    My question was, "If the first mov r0 didn't take, how do you know that the second one always would?"

    Jon

Children