18LF2520 as PWM TIMER or LOOP? (Oshonsoft BASIC)

Discussion in 'Embedded Systems and Microcontrollers' started by camerart, May 27, 2018.

  1. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    859
    34
    Hi,
    Here's a program where I've joined a TIMER program which works and a SERIAL IN program that also works, but together they don't.

    If the line with ################### is in the program, then the TIMER works, and if it's commented out then the SERIAL IN works. (Copy and paste '$1100,1200,1300,1400,1500,1600,?' into the HSERIN in the SIM)

    Any ideas please?
    Camerart
     
  2. ericgibbs

    Moderator

    Jan 29, 2010
    5,962
    1,125
    hi C,
    You have not said which Timer.? I guess Oshonsoft is using the timer for PWM timing, so try a different Timer.
    E
     
  3. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    859
    34
    Hi E,
    I used a program that you wrote years ago, using TMR1. I've been looking at it, and it could be that TMR0 should have been used, but I'm not sure. I'll try it.

    EDIT: I've just noticed that in the LOOP part of the program, it uses PIR which is part of a TIMER set up, so must be clashing with the TIMER (TMR1) section. I'll have to start again and try TMR0.

    C.
     
    Last edited: May 27, 2018
  4. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    859
    34
    Hi E,
    I'm trying a test for PWM. A timer (Now TMR0) sets the 20MS LOOP required for the SERVOS, and within this LOOP I will add 6x ON/OFFs using RB0-5.

    In the MAIN LOOP, is your modified NMEA sentence stripper, that I have changed for the incoming serial DATA for the PWM outputs.

    I hope I've been clear?
    Here is the TMR0 test program. It may be working ok?
    C.
     
    Last edited: May 27, 2018
  5. camerart

    Thread Starter Well-Known Member

    Feb 25, 2013
    859
    34
    Hi,
    Here's the program with the TMR0 this time, which appears to be working now.
    Next I've got to figure the TMR0 LOOP time, I've got to set it to 20MS.

    EDIT: A few errors corrected.

    C.
     
    Last edited: May 29, 2018
Loading...