Hi,
What do you mean by "a better way"? One that executes faster or takes less codespace or looks "cleaner" or just "generally" better?
Calculating the values will almost certanly increase the execution time (run slower) but might produce less code than a bunch of lookup tables. PBP do have SIN/COS/ATN which might be useful if you're dealing with circles, angles etc but again, it'll probably be slower than a lookuptable.
Using HSEROUT as Joe suggests will allow the program to continue execute while the byte is being sent. To gain the most out of it you'll need to place the HSEROUT between each lookup, like:
Code:
LOOKUP z, [$00, $00, $00, $01], x1 'Get x1
HSEROUT [x1] 'Send x1
LOOKUP z, [$00, $33, $88, $FF], x2 'Now get x2 while x1 is being sent in the background.
HSEROUT [x2] 'It's likely that x1 isn't fully sent yet so HSEROUT will "hang" until there's room in TXREG.
LOOKUP z, [$00, $00, $01, $01], y1
HSEROUT [y1]
LOOKUP z, [$00, $3C, $A1, $FF], y2
HSEROUT [y2]
That will make it lookup "the next" byte while the previous one is being sent. Lookup is most likely way faster than the time it takes the USART to send the byte so sending the data is still the bottleneck, I think.
Obviously you can replace the individual HSEROUT statements with a GOSUB by placing the looked up byte in the same variable each time.
/Henrik.
Bookmarks