Author Topic: PMS150 PWM generator  (Read 391 times)

0 Members and 1 Guest are viewing this topic.

Offline itelite

  • Contributor
  • Posts: 23
  • Country: us
PMS150 PWM generator
« on: August 15, 2019, 09:36:44 pm »
Fellow Nerds.  Trying out the PMS150 and more than a bit lost in this language and IDE. Hoping someone can point me in the right direction.

Goal: Fixed frequency PWM output with duty based on the state of 2 pins. high or low state.

I see that there is demo code that looks like it does this but it does not compile when you switch the chip to PMS150.  It gives some errors that i simply do not know what they mean, and what the remediation would be. 

Also in the manual/help it states there is a PWM module under "generate code" and at least for that module is missing. 

Code:
#include   "extern.h"

BYTE   pwm_duty;   //   Modify pwm_duty, then FPPA change the PWM duty

void   FPPA0 (void)
{
   .ADJUST_IC   8MIPS      // IHRC/2 = 8MIPS, WatchDog Disable, RAM 0,1 temporary be used

   pwm_duty   =   0;

   pmode   Program_Mode;         //   if has more FPPAs than 2

   fppen   =   0xFF;

   BIT      Sync   :   PA.0;
   BIT      f_Duty_Dn;

   $ Sync   Out, Low;

   while (1)
   {
      WORD   count   =   0x5678;   //   Only for delay
      while (1)
      {
         $ Sync   Tog;
         .delay   PWM_CYCLE - 5;
         count--;
         if (CF)   break;
      }
      nop
      $ Sync   Tog;

      if (! f_Duty_Dn)
      {
         if (pwm_duty >= PWM_CYCLE)
         {
            f_Duty_Dn   =   1;
            pwm_duty--;
         }
         else
         {
            pwm_duty++;
         }
      }
      else
      {
         if (! pwm_duty)
         {
            f_Duty_Dn   =   0;
            pwm_duty++;
         }
         else
         {
            nop
            pwm_duty--;
         }
      }
      .delay   PWM_CYCLE - 13;
   }
}


Errors:
C:\PADAUK_Tool\0.87\Demo\PWM\PWM.C(8): Syntax error happen !!!
C:\PADAUK_Tool\0.87\Demo\PWM\PWM.C(12): Syntax error : 'pmode'
C:\PADAUK_Tool\0.87\Demo\PWM\PWM.C(14): Syntax error : 'fppen'
C:\PADAUK_Tool\0.87\Demo\PWM\PWM.C(26): The 'TOG' not be supported at Assembly
C:\PADAUK_Tool\0.87\Demo\PWM\PWM.C(32): The 'TOG' not be supported at Assembly

pmode seems to be related to running multiple differnt FPPA, and i can comment it out.
fppen seems to be the default choice of those to run.  i can comment it out.

Syntax error happen, i just have no idea.
TOG no idea.

If there is an other way to do this i am all ears of course. I thought i would start with the demo code to see what happens.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf