Hi, you can use the PWM-Ports as Output, but only Output. last Year I tried the PWM as output, The File should work as main.c in an embedded Project with Flash und External Ram (I do not know if it is really nessesairy) The Variables for the PWM_Register are only for look at Registers. I think only the PM_OUT could be interesting. For Information about the Registers look up in the Family Manual (Chapter 11.7 or Appendix C Page C-88ff) The project button_pwmled is in Embedded SDK 2.4.1 I have seen. But not in SDK 2.4.0 Get it for free at e-www.motorola.com Much luck W. --- In motoroladsp@y..., "hancicimen" <hanc@c...> wrote: > > We plan use 56F803 and 807 in our applications. I just wonder if we > can use PWM outputs as standart Output? Since the I/O is very limited > with 56F803 we need more I/O. (For LCD, keypad, input and outputs > etc.) As far as I understand Fault pins, current sense pins and > Quadrature decoder pins can be used as ordinary input. Is it correct? > > Best regards, > > HAN -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net |
/* File: main.c */ #include "port.h" #include "io.h" #include "fcntl.h" #include "bsp.h" #include "led.h" #include "pwm.h" //Pulse Width Modulator #include "mc.h" #include "timer.h" #define PWMA_BASE 0x0E00 /* Base Adress for PWM (only A available on 803) */ void main (void) { struct timespec HalfSecond = {0, 500000000}; /* PWM Registers */ UWord16 *PMCTL = (UWord16*)(PWMA_BASE); UWord16 *PMFCTL = (UWord16*)(PWMA_BASE + 0x0001); UWord16 *PMFSA = (UWord16*)(PWMA_BASE + 0x0002); UWord16 *PMOUT = (UWord16*)(PWMA_BASE + 0x0003); UWord16 *PMCNT = (UWord16*)(PWMA_BASE + 0x0004); UWord16 *PWMCM = (UWord16*)(PWMA_BASE + 0x0005); UWord16 *PMMVAL0 = (UWord16*)(PWMA_BASE + 0x0006); UWord16 *PMMVAL1 = (UWord16*)(PWMA_BASE + 0x0007); UWord16 *PMMVAL2 = (UWord16*)(PWMA_BASE + 0x0008); UWord16 *PMMVAL3 = (UWord16*)(PWMA_BASE + 0x0009); UWord16 *PMMVAL4 = (UWord16*)(PWMA_BASE + 0x000A); UWord16 *PMMVAL5 = (UWord16*)(PWMA_BASE + 0x000B); UWord16 *PMDEADTM = (UWord16*)(PWMA_BASE + 0x000C); UWord16 *PMDISMAP1 = (UWord16*)(PWMA_BASE + 0x000D); UWord16 *PMDISMAP2 = (UWord16*)(PWMA_BASE + 0x000E); UWord16 *PMCFG = (UWord16*)(PWMA_BASE + 0x000F); UWord16 *PMCCR = (UWord16*)(PWMA_BASE + 0x0010); UWord16 *PMPORT = (UWord16*)(PWMA_BASE + 0x0011); /* End of PWM Registers */ int LedFD = 0; int pwmFD = 0; int i=0, j=8; /* Turns the USER_LED LED 8 on off */ /* open LED driver */ LedFD = open(BSP_DEVICE_NAME_LED_0, 0); /* turn Green LED on/off */ ioctl(LedFD, LED_OFF, LED_GREEN); //, BSP_DEVICE_NAME_LED_0); for (i=0; i<20;i++) { ioctl(LedFD, LED_OFF, LED_GREEN); nanosleep(&HalfSecond, NULL); } /* close LED driver */ close(LedFD); /* END of USER_LED */ /* PWM_LED Controling LED2 .. LED7 */ /* OPEN PWM_LED driver */ pwmFD = open(BSP_DEVICE_NAME_PWM_A, 0); /* control*/ /* enable output */ ioctl(pwmFD, PWM_DEVICE, PWM_ENABLE); ioctl(pwmFD, PWM_OUTPUT_PAD, PWM_ENABLE); ioctl(pwmFD, PWM_SET_INDEPENDENT_OPERATION, PWM_CHANNEL_01| PWM_CHANNEL_23 |PWM_CHANNEL_45); ioctl(pwmFD, PWM_OUTPUT_SOFTWARE_CONTROL, MC_PWM_ALL_SIGNALS); i=0; while (i<64) { ioctl(pwmFD, PWM_OUTPUT_CONTROL, i);// BSP_DEVICE_NAME_PWM_A); i++; nanosleep(&HalfSecond, NULL); }; return; /* C statements */ } |