PDA

View Full Version : tables using PBP and asm command retlw



queenidog
- 23rd May 2012, 00:14
I'm working on a 32 bit POV project and have the hardware all sorted out and tested with a small PBP program that sends out Ascii characters from a string "This is a Test". I used the LOOKUP command to read the bytes and output to the 32 light-thingy which I verify is displaying four bytes of Ascii text.

Now it's time to send an actual drawing of sorts using a bigger table (more than 14 bytes in "This is a Test"). My table is 255 bytes long and I get the dreaded "unable to fit variable" error because page boundary limitation.

I read many posts on this forum and Google search and see various ways around the issue but I don't know which is easiest or applicable.

I saw a method where the user created a table (the program was all in assembler) that began like this:

ImageData ADDWF PCL,F
; Page boundary, image data starts here. There are 255 rows each one byte long
RETLW B'10101010'
RETLW B'11111111'
RETLW B'00000000'

Can I jump to this table with a Call? How do I integrate the two programs (one in PBP and the other-the data table-in assembler)?
What housekeeping, initialization do I have to do to get the programs working together?

Can I/should I/ use Writecode-Readcode per Melanie's document? Isn't RETLW easier? Data is constant, not variable.

I haven't done any assembler programming with this PIC 16F628 and just started with PicBasic Pro.

Acetronics2
- 23rd May 2012, 17:52
Hi, Queenidog

Don't you know the LOOKUP command exactly does that ??? ( much simpler, no ??? ...)

you also could play with POKECODE and PEEKCODE ... :friendly_wink: to make things a bit funny ...





'************************************************* ****************************
PwmLoop: ' 165 steps per sec. = ... 3ms per loop
'************************************************* ****************************

'Short loop 24 > 336 µs

IF ( Sampled >= 31 ) then ' No light if Sampled < 31

Delay2 = 0
peekcode ( 850 + sampled ), delay ' 881 = 850 + 31 !!!

IF Sampled >= 87 Then Longloop

IF Sampled >= 79 THEN Delay2 = 1 ' Add 255 to Pauseus...using BYTE

Strob_led = 1

Pauseus delay
IF Delay2 Then Pauseus 255

Strob_led = 0

ENDIF
delay = 0

Longloop:

For x = 0 to 13 ' min 336 µs

IF delay then Strob_led = 1 'Skip min Pauseus ...

Pauseus delay

Strob_led = 0

Pauseus Duration - delay

next x
RETURN

....


'************************************************* ****************************
'Fading_Table
'************************************************* ****************************
' 0 1 2 3 4 5 6 7 8 9
'
Pokecode @881, 24, 27, 29, 32, 35, 38, 41, 44, 47,_ ' 30
50, 54, 57, 60, 64, 68, 71, 75, 79, 83,_ ' 40
87, 91, 96,100,104,109,113,118,123,127,_ ' 50
132,137,142,147,153,158,163,169,174,180,_ ' 60
186,191,197,203,209,212,217,245,250, 1,_ ' 70
7, 13, 21, 30, 39, 48, 57, 24, 25, 26,_ ' 80
27, 28, 29, 30, 31, 32, 33, 34, 35, 36,_ ' 90
37, 38, 39, 40, 41, 43, 44, 45, 46, 48,_ ' 100
49, 50, 52, 53, 54, 56, 57, 59, 60, 62,_ ' 110
63, 65, 67, 68, 70, 72, 73, 75, 77, 79,_ ' 120
81, 83, 84, 86, 88, 90, 92, 94, 97, 99,_ ' 130
101,103,105,107,110,112,114,117,119,122,_ ' 140
124,126,129,132,134,137,139,142,145,148,_ ' 150
150,153,156,159,162,165,168,172,176,180 ' 160


Alain

queenidog
- 23rd May 2012, 21:01
I was using Lookup but the table size is restricted by page boundaries (thus only 96 characters can be stored in a table).

Here's the code I was using for a small data table:

Start:
y=0:z=1
For x= 0 to 15 'reading 16 bytes/characters from table Imagebyte
lookup x, ["THIS IS A TEST"], imagebyte
GoSub Writebyte
next x
goto Start


Writebyte: 'Subroutine to send serial image data to shift registers
y=y+1
'high clockpin This statement NOT NEEDED
shiftout datapin,Clockpin,MSBFirst,[imagebyte] 'shift out imagebyte one bit at a time
'low clockpin This statement NOT NEEDED
lcdout $fe, 1 'clear display
lcdout $FE, $14 , imagebyte 'Display value on LCD
Low PORTE.2 'strobe for LCD
'pause 200
z=y//4 'get modulus (remainder) remainder is only zero when 4 divides
If z=0 then 'evenly into x (4/4= 1, 0 remainder, 8/4=2, 0 remainder
high Latch '4 bytes in registers, ie 32 bits so enable both register latches
pause 1 'pause 1 mS may not need.
outena=0 ' I have 4 bytes, light up LEDs

Are you saying I can use Pokecode to create my table of values, and Peekcode to retrieve them? 255 values ? You have about 150 values in your table example below. What does your program do?

queenidog
- 23rd May 2012, 23:56
Alain, thanks for the tip about using PokeCode and Peekcode. This did the trick. I put 255 values in a table and was able to read everyone of them. So simple...

Why is Melanie saying to use Writecode/Readcode? What is the difference?

And why does PokeCode work where Lookup doesn't (any more than 96 values and it cacks)? In the PBP manual it states that Lookup and Arrayread can have 255 values. Is this an error, or just not the "whole truth"?

financecatalyst
- 7th June 2012, 22:47
I am trying to understand the table method and I came across this example. I am having trouble visualizing (Alain's fading table) this method as to how it will be an equivalent table in lets say in an excel file. I mean will it just be row numbers (starting from lets say 881) and 1 column with all the stored values one below the other starting from 24, and why is "_" sign is there in the table :confused:, I don't know if I have made my question clear, but I can try explain differently if needed :)