void SetOutputEPWM1(unsigned char outputconfig, unsigned char outputmode) { /* set P1M1 and P1M0 */ outputconfig |= 0b00111111; outputmode |= 0b11111100; ECCP1CON = (ECCP1CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ ECCP1CON = (ECCP1CON | 0b00001111) & outputmode; //-------------------------------------- #if defined(PWM14_2_IO_V2) if (SINGLE_OUT == outputconfig) { TRISDbits.TRISD4 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISDbits.TRISD4 = 0; TRISDbits.TRISD5 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISDbits.TRISD4 = 0; TRISDbits.TRISD5 = 0; TRISDbits.TRISD6 = 0; TRISDbits.TRISD7 = 0; } #elif defined(PWM14_2_IO_V1) if (SINGLE_OUT == outputconfig) { TRISBbits.TRISB4 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISBbits.TRISB4 = 0; TRISBbits.TRISB1 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISBbits.TRISB4 = 0; TRISBbits.TRISB1 = 0; TRISBbits.TRISB2 = 0; TRISBbits.TRISB3 = 0; } #endif //--------------------------------------------- }
void SetOutputEPWM1(unsigned char outputconfig, unsigned char outputmode) { /* set P1M1 and P1M0 */ outputconfig |= 0b00111111; outputmode |= 0b11111100; ECCP1CON = (ECCP1CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ ECCP1CON = (ECCP1CON | 0b00001111) & outputmode; //-------------------------------------- if (SINGLE_OUT == outputconfig) { TRISCbits.TRISC2 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISCbits.TRISC2 = 0; TRISBbits.TRISB2 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISBbits.TRISB4 = 0; TRISBbits.TRISB1 = 0; TRISCbits.TRISC2 = 0; TRISBbits.TRISB2 = 0; } //--------------------------------------------- }
void SetOutputEPWM1(unsigned char outputconfig, unsigned char outputmode) { // #define __CONFIG3H 0x300005 // #define __ECCPMX 1 /* bit 1 of __CONFIG3H */ // static char eccpmx; /* will be set iff bit 1 of __CONFIG3H is set */ // set P1M1 and P1M0 ECCP1CON = (ECCP1CON | 0b11000000) & outputconfig; // set CCP1M3, CCP1M2, CCP1M1, CCP1M0 ECCP1CON = (ECCP1CON | 0b00001111) & outputmode; if (SINGLE_OUT == outputconfig) { TRISDbits.TRISD4 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISDbits.TRISD4 = 0; TRISDbits.TRISD5 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISDbits.TRISD4 = 0; TRISDbits.TRISD5 = 0; TRISDbits.TRISD6 = 0; TRISDbits.TRISD7 = 0; } }
void SetOutputPWM2(unsigned char outputconfig, unsigned char outputmode) { char pmmode; /* will be set iff bit 0 AND bit 1 of __CONFIG3L are set */ char ccp2mx; /* will be set iff bit 0 of __CONFIG3H is set */ unsigned char TBLPTR_U, TBLPTR_L; _asm movff TBLPTRU, TBLPTR_U movff TBLPTRL, TBLPTR_L _endasm /* set P1M1 and P1M0 */ CCP2CON = (CCP2CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ CCP2CON = (CCP2CON | 0b00001111) & outputmode; #if defined (PWM_CONFIG3L_V1) || defined (PWM_CONFIG3L_V2) if (((*(unsigned char far rom *)__CONFIG3H) & 0b00000001)) ccp2mx=0xff; else ccp2mx = 0; #endif #if defined PWM_CONFIG3L_V1 if (((*(unsigned char far rom *)__CONFIG3L) & 0b00000011) == 0b00000011) pmmode=0xff; else pmmode = 0; #elif defined PWM_CONFIG3L_V2 if (((*(unsigned char far rom *)__CONFIG3L) & 0b00110000) == 0b00110000) pmmode=0xff; else pmmode = 0; #endif #if defined PWM2_IO_V5 if (SINGLE_OUT == outputconfig) { if(ccp2mx) TRISCbits.TRISC1 = 0; else TRISEbits.TRISE7 = 0; } else if (IS_DUAL_PWM(outputconfig)) { if(ccp2mx) TRISCbits.TRISC1 = 0; else TRISEbits.TRISE7 = 0; TRISEbits.TRISE2 = 0; } else if (IS_QUAD_PWM(outputconfig)) { if(ccp2mx) TRISCbits.TRISC1 = 0; else TRISEbits.TRISE7 = 0; TRISEbits.TRISE2 = 0; TRISEbits.TRISE1 = 0; TRISEbits.TRISE0 = 0; } #elif defined PWM2_IO_V3 if (SINGLE_OUT == outputconfig) { TRISCbits.TRISC1 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISCbits.TRISC1 = 0; TRISEbits.TRISE2 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISCbits.TRISC1 = 0; TRISEbits.TRISE2 = 0; TRISEbits.TRISE1 = 0; TRISEbits.TRISE0 = 0; } #elif defined PWM2_IO_V6 if (SINGLE_OUT == outputconfig) { if(ccp2mx) TRISCbits.TRISC1 = 0; else if(pmmode) TRISEbits.TRISE7 = 0; else TRISBbits.TRISB3 = 0; } else if (IS_DUAL_PWM(outputconfig)) { if(ccp2mx) TRISCbits.TRISC1 = 0; else if(pmmode) TRISEbits.TRISE7 = 0; else TRISBbits.TRISB3 = 0; TRISEbits.TRISE2 = 0; } else if (IS_QUAD_PWM(outputconfig)) { if(ccp2mx) TRISCbits.TRISC1 = 0; else if(pmmode) TRISEbits.TRISE7 = 0; else TRISBbits.TRISB3 = 0; TRISEbits.TRISE2 = 0; TRISEbits.TRISE1 = 0; TRISEbits.TRISE0 = 0; } #endif _asm movff TBLPTR_U, TBLPTRU movff TBLPTR_L, TBLPTRL _endasm }
void SetOutputPWM3(unsigned char outputconfig, unsigned char outputmode) { #define __CONFIG3H 0x300005 char eccpmx; /* will be set iff bit 1 of __CONFIG3H is set */ unsigned char TBLPTR_U, TBLPTR_L; _asm movff TBLPTRU, TBLPTR_U movff TBLPTRL, TBLPTR_L _endasm /* set P1M1 and P1M0 */ CCP3CON = (CCP3CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ CCP3CON = (CCP3CON | 0b00001111) & outputmode; #if defined (PWM1_IO_V4) if (((*(unsigned char far rom *)__CONFIG3H) & 0b00000010)) eccpmx=0xff; else eccpmx = 0; #endif #if defined PWM3_IO_V1 if (SINGLE_OUT == outputconfig) { TRISDbits.TRISD1 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISDbits.TRISD1 = 0; TRISEbits.TRISE4 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISDbits.TRISD1 = 0; TRISEbits.TRISE4 = 0; TRISEbits.TRISE3 = 0; TRISDbits.TRISD2 = 0; } #elif defined PWM3_IO_V2 if (SINGLE_OUT == outputconfig) { TRISGbits.TRISG0 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISGbits.TRISG0 = 0; TRISEbits.TRISE4 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISGbits.TRISG0 = 0; TRISEbits.TRISE4 = 0; TRISEbits.TRISE3 = 0; TRISGbits.TRISG3 = 0; } #elif defined PWM3_IO_V2 if (SINGLE_OUT == outputconfig) { TRISGbits.TRISG0 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISGbits.TRISG0 = 0; if(eccpmx) TRISEbits.TRISE4 = 0; else TRISHbits.TRISH5 = 0; } else if (IS_QUAD_PWM(outputconfig)) { TRISGbits.TRISG0 = 0; if(eccpmx) {TRISEbits.TRISE4 = 0;TRISEbits.TRISE3 = 0;} else {TRISHbits.TRISH5 = 0;TRISHbits.TRISH4 = 0;} TRISGbits.TRISG3 = 0; } #endif _asm movff TBLPTR_U, TBLPTRU movff TBLPTR_L, TBLPTRL _endasm }
void SetOutputEPWM1(unsigned char outputconfig, unsigned char outputmode) { char eccpmx=0; /* will be set iff bit 1 of __CONFIG3H is set */ unsigned char TBLPTR_U, TBLPTR_L; _asm movff TBLPTRU, TBLPTR_U movff TBLPTRL, TBLPTR_L _endasm /* set P1M1 and P1M0 */ outputconfig |= 0b00111111; outputmode |= 0b11111100; #if defined (EPWM_V14_3) || defined (EPWM_V14_4) CCP1CON = (CCP1CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ CCP1CON = (CCP1CON | 0b00001111) & outputmode; #else ECCP1CON = (ECCP1CON | 0b11000000) & outputconfig; /* set CCP1M3, CCP1M2, CCP1M1, CCP1M0 */ ECCP1CON = (ECCP1CON | 0b00001111) & outputmode; #endif #if defined (PWM_V14_IO_V1) || defined (PWM_V15_IO_V1) || defined (PWM_V15_2_IO_V1) if (((*(unsigned char far rom *)__CONFIG3H) & 0b00000010)) eccpmx=0xff; else eccpmx = 0; #endif //-------------------------------------- if (SINGLE_OUT == outputconfig) { TRISCbits.TRISC2 = 0; } else if (IS_DUAL_PWM(outputconfig)) { TRISCbits.TRISC2 = 0; #if defined (PWM_V14_IO_V1) || defined (PWM_V15_IO_V1) if(eccpmx) TRISEbits.TRISE6 = 0; else TRISHbits.TRISH7 = 0; #elif defined (PWM_V15_2_IO_V1) if(eccpmx) TRISEbits.TRISE6 = 0; #elif defined (PWM_V14_IO_V2) TRISEbits.TRISE6 = 0; #endif } else if (IS_QUAD_PWM(outputconfig)) { TRISCbits.TRISC2 = 0; #if defined (PWM_V14_IO_V1) || defined (PWM_V15_IO_V1) if(eccpmx) {TRISEbits.TRISE6 = 0;TRISEbits.TRISE5 = 0;} else {TRISHbits.TRISH7 = 0;TRISHbits.TRISH6 = 0;} TRISGbits.TRISG4 = 0; #elif defined (PWM_V15_2_IO_V1) if(eccpmx) TRISEbits.TRISE6 = 0; TRISEbits.TRISE5 = 0; TRISGbits.TRISG4 = 0; #elif defined (PWM_V14_IO_V2) TRISEbits.TRISE6 = 0; TRISEbits.TRISE5 = 0; TRISGbits.TRISG4 = 0; #endif } //--------------------------------------------- _asm movff TBLPTR_U, TBLPTRU movff TBLPTR_L, TBLPTRL _endasm }