USART TX Interrupt problem. (DT_INTS)


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: USART TX Interrupt problem. (DT_INTS)

    Because the interrupt messed up my array of data and the HSEROUT statements helped me show what was going on. Which turned out to be that I hadn't declared the array properly.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: USART TX Interrupt problem. (DT_INTS)

    Yeah, I understand that but, Why don't you just load the array with your message and then enable the interrupt? You have the code there already.. The interrupt will disable it when the message is sent... I have used this methode for the last few years but not with the ARRAYREAD or ARRAYWRITE statements... Just loose the HSEROUT stuff.... THat way it's all done in the background...
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: USART TX Interrupt problem. (DT_INTS)

    Dave,
    That was the purpose all along and that is exactly what I did - but it didn't work, it just gave me garbage as you can see in my first post. So I added the HSEROUT statements to help debug the problem which, again, was my erronous array declaration. Now when teh problem is found and fixed the HSEROUT statements are gone.

    The code isn't "production code" it's code to illustrate the problem I had with the interrupt routine corrupting my array.

    /Henrik.

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: USART TX Interrupt problem. (DT_INTS)

    Henrik, Yes I understand now. However if you are going to use this routine:
    '-- Interrupt service rotuine for USART TX Interrupt ---------------
    USART_TX:
    TXReg = String_1[TxPointer] ' Load character from array into USART TX register
    If String_1[TxPointer] = 0 then ' If that character was a NULL we're done so we.....
    @ INT_DISABLE TX_INT ; ...disable the any further USART TX interrupts.
    ELSE ' If the character was not a CR we.....
    TxPointer = TxPointer + 1 ' ...increase the pointer, prepare to send the next character.
    ENDIF ' As soon as the TX-reg is empty the interrupt will fire again. (~1ms at 9600baud)
    @ INT_RETURN

    I would check for the end of the string before I send the a character, That way you won't be sending the null character from the end of the array. You will get an interrupt when the last character is sent and at that time you don't want to be sending any more, just disable the interrupt and leave.... just change the routine to read:

    '-- Interrupt service rotuine for USART TX Interrupt ---------------
    USART_TX:
    If String_1[TxPointer] = 0 then ' If that character was a NULL we're done so we.....
    @ INT_DISABLE TX_INT ; ...disable the any further USART TX interrupts.
    ELSE ' If the character was not a CR we.....
    TXReg = String_1[TxPointer] ' Load character from array into USART TX register
    TxPointer = TxPointer + 1 ' ...increase the pointer, prepare to send the next character.
    ENDIF ' As soon as the TX-reg is empty the interrupt will fire again. (~1ms at 9600baud)
    @ INT_RETURN
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: USART TX Interrupt problem. (DT_INTS)

    Hi Dave,
    Good point! I cut and pasted the routine from a working program in which I used 13 as the string terminator - which I did want to send. With NULL as the terminator checking it first is of course better.

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts