Help using dsPIC33 to generate 50Hz sine wave

Discussion in 'Embedded Systems and Microcontrollers' started by yan_c, Jun 23, 2011.

  1. yan_c

    Thread Starter New Member

    Jun 17, 2011
    8
    0
    Hi, I am trying to get a dsPIC33FJ256MC710 to produce a 50Hz Sine wave o/p from a LUT. I now have some basic working code but I need to clarifty a few things regarding the PWM registers as there is no sine wave o/p as yet!

    PTPER reg is the PWM period reg and is pre-set with a value for this period.
    PTMR is the timer that is used to count up to this value.
    and PDC1 is the scaled PWM on-time value that is loaded from the sine LUT for that PWM period.

    Once the timer is started eventually PTMR = PTPER and I presume a flag is set so the PTMR reg can be reset, a new value is reloaded into PDC1 from the LUT and the process repeats...

    Can anyone tell me which flag I can use to tell me when PTMR = PTPER, is this just an interrupt flag or do you need to use O/P Compare registers?

    Also how do I use the the LUT values to give the "ON" time for that period?

    Any help would be most appreciated..

    Thanks
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Can you take a step back and say HOW you're trying to accomplish your task? Why are you using PWM stuff to generate a sine wave? A LUT should be all you really need, as far as I can tell.

    There should be a flag that tells you when a timer overflows... Look in the datasheet under that timer module's section. It will tell you everything you need to know, including the name of the interrupt flag
     
Loading...