Need some help with SXB PWM code.. (Getting error _TrisC)
Hi guys,
Just got my SX Blitz key today and my SX48 Proto Board, and I have been running through the new draft of the Practical SXB book.
On the experiment that talks about PWM (page 83) they give me a piece of code to try and it keeps giving me an error every time I try and use it.
Here is the code ( I moded it to work with my 48chip )
The error I get is " line 93, error 3, pass 2: Symbol <_TrisC> is not defined" And the same error appears on line 127.
This error is in the assembled code
Here is the assembled code:
Whats going on here? I have checked over my code several times and tried several different things...
It might just be that I am trying to do this at 1:21 AM :P and it's entirely possible that in the morning it will be obvious to me... but I thought I would check here first..
Thanks guys
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio
Post Edited (Kd7lax) : 9/8/2007 8:24:58 AM GMT
Just got my SX Blitz key today and my SX48 Proto Board, and I have been running through the new draft of the Practical SXB book.
On the experiment that talks about PWM (page 83) they give me a piece of code to try and it keeps giving me an error every time I try and use it.
Here is the code ( I moded it to work with my 48chip )
DEVICE sx48, OSC4mhz FREQ 4_000_000 Led PIN RC.0 duty VAR Byte PROGRAM Start Start: DO FOR duty = 0 TO 254 PWM Led, duty, 2 NEXT FOR duty = 255 TO 1 STEP -1 PWM Led, duty, 2 NEXT PAUSE 50 Loop
The error I get is " line 93, error 3, pass 2: Symbol <_TrisC> is not defined" And the same error appears on line 127.
This error is in the assembled code
Here is the assembled code:
SETB IND.0 MOV W,#$1F MOV M,W MOV !RC,IND MOV FSR,#$10 CJAE duty,#254,@__NEXT_duty_1 ; NEXT INC duty JNZ @__FOR_duty_1 __NEXT_duty_1: MOV duty,#255 ; FOR duty = 255 TO 1 STEP -1 __FOR_duty_2: MOV FSR,#__TRIS ; PWM Led, duty, 2 MOV W,#$0F MOV M,W MOV !RC,W MOV IND,W MOV W,#$1F MOV M,W CLRB IND.0 MOV !RC,IND MOV FSR,#$10 MOV __PARAM1,#2 CLR __PARAM2 MOV __PARAM3,#2 MOV __PARAM4,#108 ADD __PARAM2,duty MOVB Led,C DJNZ __PARAM4,@$-6 DJNZ __PARAM3,@$-9 DJNZ __PARAM1,@$-16 [color=#009900]MOV FSR,#__TRISC // It Highlighted this when I ran the debugger [/color] SETB IND.0 MOV W,#$1F MOV M,W MOV !RC,IND MOV FSR,#$10 CJBE duty,#1,@__NEXT_duty_2 ; NEXT SUB duty,#1 JC @__FOR_duty_2 __NEXT_duty_2: MOV __PARAM2,#50 ; PAUSE 50 MOV __PARAM3,#4 MOV __PARAM4,#28 DJNZ __PARAM4,@$ DJNZ __PARAM3,@$-3 DJNZ __PARAM2,@$-10 JMP @__DO_1 ; Loop __LOOP_1:
Whats going on here? I have checked over my code several times and tried several different things...
It might just be that I am trying to do this at 1:21 AM :P and it's entirely possible that in the morning it will be obvious to me... but I thought I would check here first..
Thanks guys
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio
Post Edited (Kd7lax) : 9/8/2007 8:24:58 AM GMT
Comments
This is a known issue when using PWM on the SX48.
See this thread for the work-around http://forums.parallax.com/showthread.php?p=597707
This should work:
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The first rule to being successful is "Learn from your mistakes",
The second rule is "Be willing to make mistakes"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio
I am going with this approach using some Allegro A6821 (which are simply serial versions of UDN2803's). Their cascadable 3-pin interface (Data, Clock, and Strobe) should work like 74HC595's so It should not be too difficult. However I may use some N-Channel FETS between the cathodes and the A6821's to allow for more current in scrolling in all directions (not just left and right).
How does this hardware STroBing (PWM) compare with PWM control in software for the SX-28 or 48, etc..?
Post Edited (T&E Engineer) : 9/9/2007 10:41:30 AM GMT
There are various methods. PWM, PFM, etc.
The analog way to control intensity would be to generate an analog voltage, and use that voltage to control the current to the device. But PWM does it in a purly digital way.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The first rule to being successful is "Learn from your mistakes",
The second rule is "Be willing to make mistakes"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·