Can you use the usart serial port? Serout & serout2 are bit bang serial output and
S L O W your MCU, even debug might be faster.
Can you use the usart serial port? Serout & serout2 are bit bang serial output and
S L O W your MCU, even debug might be faster.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
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: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.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]
Obviously you can replace the individual HSEROUT statements with a GOSUB by placing the looked up byte in the same variable each time.
/Henrik.
Since it is not clear to me what you want to acheive, I will attach a simple program in VB6 from which you can see how to use maths for drawing as many points you want on any given circle. All the maths are inside command1_click and should be not too difficult for you to translate the VB code into PBP code.
Cheers
Al.
All progress began with an idea
I tried using sin/cos calculations and it resulted in the same speed or maybe slightly slower. I am only using 9600 baud out. This may be where im hanging up. I didnt figure that it would be the bottleneck in the operation. The next test will be to bump up the baud rate and see what happens.
EDIT: I changed over to the USART and set it up at 19200 and sure enough its displaying the gauge points twice as fast. Now, I have to tie the 2 USART transmit pins together because I have to initiate communication with the GPU at 9600 baud and then change the baud rate. I need to change the baud rate for one USART on the fly and re-DEFINE-ing the baud rate doesnt seem to work.
Last edited by sccoupe; - 2nd May 2011 at 21:51.
I think you will have to address the baud rate reg directly if you want to change on the fly. As near as I can tell, DEFINE will only work once in the program. Someone correct me if I am wrong
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
You can change the baud rate "on the fly". I generally try to find a combination of BRGH and BRG16 that will give me both of the baud rates that I want with writing only to SPBRG.
I normally run at 40Mhz, so with the following in the header
DEFINE HSER_RCSTA 90H
DEFINE HSER_TXSTA 24H
DEFINE HSER_CLROERR 1
Then, in the main program...
You can run at 9600 baud with the statement:
SPBRG = 255
Or at 57600 baud with the statement:
SPBRG = 42
Charles Linquist
Bookmarks