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.
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.
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
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.
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
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.
Bookmarks