Heh...
That's my code snipped from a year or so ago.
It does work, and it's dead stable. But you need to understand that it's only a subroutine, called from the main program loop. You get to write the main loop.
The reason for not using HSERIN is that I found there was a slight startup delay when using the command. Using PULSIN to find the break, then calling HSERIN took too long and I was losing data. As you may know, the make-after-break signal can in some cases only be a few microseconds long.
At 20 MHz, you get 5 assembly instructions per microsecond, which may not be enough.
When I first wrote the code I didn't dig too deeply in PBP's internals to see what exactly was happening when HSERIN was invoked. But it seemed like an overhead issue within the command.
And note that the 'skip' function which can be used as part of HSERIN is only byte sized. So 'skip 254' works but 'skip 257' doesn't.
It was easier to access the registers directly and be assured that everything was being received properly.
Note that there's absolutely no guarantee that each and every packet coming down the wire is exclusively dimmer data.
JEC
Bookmarks