Help with converting a single ended "pwmAsm" oblect to Differential mode
Siri
Posts: 220
I am trying to modify - Jev Kuznetsov - "pwmAsm: oblect to work in the diffential mode.
Attached are the original object and my modification of the code and a test code that Iam using.
With the present modified code it only works like a single ended moe and not as a differential mode.
Please help me figure out what I am doing wrong.
Thanks.
Siri
Attached are the original object and my modification of the code and a test code that Iam using.
With the present modified code it only works like a single ended moe and not as a differential mode.
Please help me figure out what I am doing wrong.
Thanks.
Siri
Comments
sCtraVal := %00101 << 26 + PinA ' Differretial mode
Where is PinB?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
I am trying to set BPIN- tried the way you suggested and also tried using MOVD as suggested prop manual page 205.Still
I am not able to set the the BPIN.
I am still a very green at PASM - so please pont out to me where I am making the error.
I have attached the modified "object" and the test code.
Thanks for all your help.
Siri
Isn't all you need to do is to OR in PinB into the 9th bit position in sCtraVal? This also implies that sPinOutA and sPinOutB are redundant for the PASM function as those values can be ascertained from sCtraVal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Post Edited (kuroneko) : 4/26/2010 7:49:45 AM GMT
As pointed out you have redundant information which you can optimize out later when you understand what is going on. For the moment, just get it working.
4Fs: Functional first, fancy final.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Siri
I did that by Initializing the " ctraval long %00101 << 26 + pinOutA + pinOutB << 9".
The object code now is:
The test code is :
In the object code I had to include a dummy variable " long adcd" and also this to the PASM code " add t1,#4
mov ctra, ctraval"
for it to work correctly.
I have attempted to remove the variable -abcde and removing "add t1,#4 from PASM - then the code does not work. also changing the PASM code after deleting addt1,#4
and changing the next code line to "add t1,#8" and this too does not work.
From all the changes I came to the conclusion that the PASM declared /Initialized are read in specific order and which I cannot figure out.
I am trying to learn PASM by looking and playing with PASM code others have written and trying yo understand.
Please can you help me with this.
Thanks
siri
The actual code is also attached.
As a quick fix, change your code like this:
Thanks you very much for your help.You explanation helped me to better understand PASM and your suggestions worked well.
I would like to write specially the PASM code to 1.set ctra register to differetial mode
2.set APIN and BPIN - using MOVS and MOVD - this will teach how to set registers with PASM.
Thanks
Siri
Thank you very much for your help.
I do not understand the following code lines.
'·enable·the·outputs·in·dira·(converts·pin·numbers·to·pin·masks)
··············"·"·mov·····t1,·#1""
················shl·····t1,·PinOutB·············'·1·<<·aBpin·(pin·mask)
················or······dira,·t1················'·activate
···············""·mov·····t1,·#1""
················shl·····t1,·PinOutA·············'·1·<<·aApin·(pin·mask)
················or······dira,·t1················'·activate
t1 was initially used to write PAR register followed by adding #4 to grt the address of Duty then Apin,Bpin etc. and since last code t1 was used to get period.Does t1 at this point has some value or does it has no value or is it only the pointer which does not retain any value at any time.
·I do uderstand "shl and or " in the code.
So if you can explain to me "mov t1,#1" this code line - the logic behind it.
Thanks for your patience and help.
Siri
So what's with that funny mov t1, #1? So far we got the pin numbers (e.g. 24 and 25) from the hub and inserted them into ctra. Now we still need the bit mask to enable those bits in dira. This is done by shifting a 1 left by the required number of bits, i.e. 1 << 24 and 1 << 25. The shl instruction takes the value to be shifted in the destination slot, the amount in the source slot. So
will take whatever is in t1 and shift it left by the amount specified in the lower 5 bits of PinOutB. The destination slot can't take immediate values like #1, meaning shl #1, PinOutB doesn't work. So we have to preload a temporary register - in this case t1 - with 1, which is where the mov t1, #1 comes in. Let's have a look at the content of t1:
So let's say for a moment we remove both mov t1, #1 instructions. What happens is that hub address of period which is still held in t1 is shifted left by aBpin, e.g. $3C8 << 25 which is $9000_0000 (as we only have 32 bits the overflow disappears). Which means bits 31 and 28 get set in dira. Subsequently this value is shifted left by aApin, e.g. $9000_0000 << 24 which results in $0000_0000. No further change to dira. Whatever the resulting value is, it's not what we wanted. We need bits 25 and 24 set. Let's re-introduce the move instructions. The first shift will then perform 1 << 25 ($0200_0000), the second one 1 << 24 ($0100_0000). Both get OR'd into dira which - as it starts empty - will then hold $0300_0000 (i.e. bits 24 and 25 set as outputs).
Basically, the only reason for the move instructions is to get the required 1 (value to be shifted) into a register.
Thank you very much.Now it is crystal clear to me except for this explaination :
"The first shift will then perform 1 << 25 ($0200_0000) and 1<< 24 ($0100_0000)
In my mind "t1" would be - % 00000000_00000000_0000000_00000001 --> prior to shift
% 00000010_00000000_00000000_00000000 -->after shift (1 <<25)
% 00000001_00000000_00000000_00000000 ---> after sfhift (1 <<24)
Dira register
> % 00000000_00000000_00000000_00000000 --- prior to "OR"
after first OR dira ---> %00000010_00000000_00000000_00000000
after 2nd OR dira ---> % 00000011_00000000_00000000_00000000 ----> pin 24 nad 25 set "Out-put"
Where did $ 0200_0000 and $ 0100_0000 come from?
Siri
p.s - You are a good teacher.
Post Edited (Siri) : 4/27/2010 10:33:41 PM GMT
Thank you very much.
I did look at your Hex notations and tried converting them to Binary using the conversion tables
and they did not make any sense.That was the reason to I posted that again.
I learned some basic facts I need to know.
Thank you very much.
Siri