We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hallo kann mir jemand sagen wie Ich ein PWM bei der Xc167 erzeugen kann ? da sind viele Register ,und Ich weisse nicht welsche ich benuzen muss ?oder in welsche Rheienfolge ich die Register inizialisieren muss ? hat jemand ein Programm wo man das sehen kann ? MFG
Here is a simple example for a PWM on CAPCOM6.
#include <xc167.h> #include <intrins.h> unsigned int update; unsigned int dc; unsigned int period; void InitCCU6(void) { /* * Configuration of CCU6 Timer 12: * ----------------------------------------------------------------------- * - prescaler factor is 1 (CPU Clock = 20MHz = T12 Clock * - clock tick = 1/20MHz = 50nsec * - timer 12 works in edge aligned mode * - 100% DC is when CCU6_CC60SR > CCU6_T12PR * - 0% DC is when CCU6_CC60SR = 0 */ CCU6_T12PR = 0x9C3F; /* load CCU6 T12 period register */ period = 0x9C3F; CCU6_CC60SR = 0x4E20; /* load CCU60 duty cycle */ dc = 0x4E20; CCU6_T12MSEL = 0x0003; /* load CCU60,COUT60 T12 compare mode */ CCU6_PSLR = 0x0000; /* load CCU60,COUT60 passive state level register */ CCU6_MODCTR = 0x0003; /* load CCU60,COUT60 modulation control register */ CCU6_T12DTC = 0x0001; /* load CCU6 dead time control register for T12 */ CCU6_CMPSTAT = 0x0200; /* COUT60 drives passive level while CC60ST is '1' */ CCU6_TCTR4 = 0x4040; /* load CCU60,COUT60 with shadow and reset T12 */ /* - P1L.0 and P1L.1 are used for CAPCOM6 outputs (CCU60,COUT60) */ ALTSEL0P1L = 0x0003; _bfld_ (P1L, 0x03,0x03); _bfld_ (DP1L,0x03,0x03); CCU6_TCTR4 = 0x0002; /* Start T12 */ } void UpdateDC(unsigned int value) { CCU6_CC60SR = value; CCU6_TCTR4 |= 0x0040; } void UpdatePeriod(unsigned int value) { CCU6_T12PR = value; CCU6_TCTR4 |= 0x0040; } void main(void) { PSW_IEN = 1; /* globally enable interrupts */ InitCCU6(); /* configure CAPCOM6 for simple PWM on P1L.0 with complement on P1L.1 */ for(;;) { /* run forever! */ if (update == 1) { UpdateDC(dc); update = 0; } if (update == 2) { UpdatePeriod(period); update = 0; } }; }