Thanks, John, for your help! I will be coding my gizmo in the next few days and those snippets will be very helpful in getting it up and running!
I'll let you know how it goes...
Thanks again--
--Alan
Thanks, John, for your help! I will be coding my gizmo in the next few days and those snippets will be very helpful in getting it up and running!
I'll let you know how it goes...
Thanks again--
--Alan
Hi John--
Well, I got it working, and its working fast, solid, stable and it is a really beautiful thing! Thank you so much for your help!
I am having one problem... I used your code as-is, and I defined a starting address before starting the loop that calls checkdmx. The problem is there's a one channel offset-- if I program in channel 5 as my target address, the device actually reads the data coming in on channel 6. If I define channel 1, it reports what's coming in on channel 2. I can't get DMX channel 1. I can't set my starting address to 0 to compensate, or when we do the subtraction that sets aminus it would underflow and seek the wrong address. What do you think is causing this? I realize I could rewrite the code to trap out this error, but since you know your code works the way you wrote it I'm wondering what could be happening here.
I also have a question-- you determine the start code by reading RCREG right after the bit is set indicating that something came into the USART following the start break with the statement startcode = rcreg. If that's all it takes to read the start code as a valid numerical byte, why do you need to use the hserin[newlevel1] statement at all? I realize my inexperience and lack of understanding about the USART is probably why I don't get it, but I am curious.
Thanks again for all your help, it has truly been invaluable!
--Alan
Two thoughts...
First, I made a typo when I posted the original code:
RCREG = dummy is bad. It should be
dummy = RCREG to clear out the buffer.
As far as catching the early data goes, it's probably more elegant to do something like
while x < aminus
'wait for a byte
'discard it
'increment x
WEND
This way, if aminus = 0 and your address = 1, the trashing routine is skipped altogether.
...
And you're exactly right - there's no reason why you should need to use HSERIN at all to grab the last byte. I was experimenting back and forth reading the registers and using HSERIN. Once I got it stable, I didn't change everything to match.
So you can leave it, or change it to say
newlevel1 = RCREG
Either way, it should work fine.
Curious - what are you building?
John
Hi John--
I tried the While:wend loop you recommended to compensate for the adrress offset, but it didn't fix it... what DID fix it was getting rid of the HSERIN command-- when I changed that to newlevel1 = rcreg, it zeroed in on the correct address! I'm wondering if the HSERIN statement has some overhead that causes it to miss that first target byte?
Regarding what I'm building, I replied to you offlist, so look for a message there.
Thanks again--
--Alan
PS: Are there any gotchas if I want to use the USART to transmit DMX?
Bookmarks