How do you set up Constans in PASM?
Philldapill
Posts: 1,283
I'm learning PASM and my first project is a modified PWM. In this, I need to have a table of duty cycle constants that will only be a byte. What I need to do, is somehow access this table each loop, set the duty cycle to whats stored in the address, increment the address pointer(or whatever it's called in PASM) and access the next variable on the next loop... etc... then go back to the start of the table, and repeat.
How do you store constants in PASM?
How do you store constants in PASM?
Comments
This will be used to quickly access an 8-bit approximation of a sinewave. I'm guessing this would be ok, but how do you get the address of Duty1? Where is this stored? How do I access these based on addresses?
mov update,#Duty1
nop
update mov t0,0-0
add update,#1
jmp update
The first line, writes the source address for the 3rd instruction to read from. the 4th instruction increments the address by 1.
Note, COG addressing is longs not bytes, either change you table to longs or you will need a bunch of long to byte fiddling
If you want a full working example, let me know and I can post some
I thought spin was pretty cool how easy it was to use, but now that I'm learning PASM, wow... so fast and powerful.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Aka: CosmicBob
mov t1,#10
movs update,#duty1
nop
update mov t0,0-0
add update,#1
djnz t1,#update
in this case you can put the mov t1,#10 in place of the nop. Also note the add update,#1 is also changing the instruction and the djnz is the 1 instruction delay
DeSilva's machine language tutorial has more information. I suggest you read it if you are getting started with PASM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔