Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Some Help Please - using dsPIC33 to generate 50Hz sine wave from LUT...

Not open for further replies.


Newbie level 4
Jun 23, 2011
Reaction score
Trophy points
Activity points
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?

Ive noticed from the dspic33 ref manual there is an int called "PWM period match flag" in IFS3 - PWMIF. It seems this flag is set when P1TMR = P1TPER which I think is what I need. I've been trying to use this by waiting for it to be set which will then mean I can load the next LUT value, but Im having problems getting it to work. Ive att the code and wondered if anyone could see where Im going wrong!

Also once this is working how does the LUT value effect the PDC "on time" - do I need to use another timer to get this to work?

Stuggling to find the exact process I need to follow to get it to work...

Any help would be most appreciated..



  • FlyWheel
    10.5 KB · Views: 81

Not open for further replies.

Part and Inventory Search

Welcome to