Shop OBEX P1 Docs P2 Docs Learn Events
Assembly PWM — Parallax Forums

Assembly PWM

jfkjfk Posts: 7
edited 2005-11-20 22:53 in General Discussion
First, an observation. The example for the 8 bit ADC in the SX/B help file works in Turbo mode but not in compatible mode. After viewing the assembly listing, I can find the loop values that control the timing. These change when you change the Freq directive, but they do NOT change if you don't use Turbo mode. A bug in the PWM function?
Now for my real question. I have coded an assembly version of the PWM function basically exactly like the basic version. And it works exactly the same as the basic version if in Turbo mode. But I need my code to run at 4MHz in compatible mode (not Turbo), and it does not work right in that configuration. I'm using the same circuit as in the example. Does any one know the loop values to use for this configuration?
Yes, I'm lazy. Right now I don't have time to sit down and figure out the timing of each instruction.
The variables in the assembly listing of the basic PWM function are:
_PARAM1 is the time in milliseconds (#1 in the example program)
_PARAM3 is the first timing value (#2 in the example)
_PARAM4 is the second timing value (#108 in the example)
Thanks for any help.

Comments

  • BeanBean Posts: 8,129
    edited 2005-11-20 04:48
    SX/B only works in TURBO mode.

    Usually you can set the FREQ to 1MHz and use TURBO then compile, then edit the SRC file and take out TURBO and change the freq to 4MHz.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    Those that would give up freedom for security will have neither.
    ·
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-11-20 17:22
    I'm just curious: Is there any specific reason why you need to run your code in "Compatibility Mode"?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-11-20 19:23
    Im with Guenther, SX compatibility mode is only for execution compatibility with a certain flavor of PICs, and as such should only be used when using an SX in a drop in replacement of a pre-existing PIC application using time critical operations. This is clearly not the case because you are creating a new program in SX/B. A very good reason for not using code compatibility in new designs·is power reduction, since turbo mode executes at 4x the speed of compatibility mode, it is better to use a resonator at 1/4 the frequency than compatibility mode and consume 1/4 the power according to P=cE^2; or, the power consumed is equal to the speed of operation times the square of the voltage. The actual power savings is less than 400% because of technical reasons but there is a power savings.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 11/20/2005 7:28:29 PM GMT
  • jfkjfk Posts: 7
    edited 2005-11-20 22:53
    Bean (Hitt Consulting) said...
    SX/B only works in TURBO mode.

    Usually you can set the FREQ to 1MHz and use TURBO then compile, then edit the SRC file and take out TURBO and change the freq to 4MHz.

    Bean.

    Thanks. I tried the values from the 1MHz listing and they don't work in 4MHz non-turbo!

    "I'm just curious: Is there any specific reason why you need to run your code in "Compatibility Mode"?"

    I'm using a lot of timed routines that, unfortunately, I used years ago. I just didn't want to go in and change all that, but it looks like I may have to.
    So, Paul, I could use a 1MHz osc. in turbo mode and it should execute the same as 4MHz non-turbo, right? I may try that or may just rewrite all my other timing code.
    And, I am not using SX/B, I'm using assembly. I'm just using the assembly version of the SX/B PWM function.
    Thanks everyone!
Sign In or Register to comment.