完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
该程序运行在16F1509。我有一个问题,把它转换成16F1615。不为我工作CLC没有信号上的RC4,我不知道为什么?我做错了什么,但是什么?运行程序16F1509。不执行程序16F1615。[附件= 16F1615YL CLC。zip ]
以上来自于百度翻译 以下为原文 The program operates on a 16F1509. I have a problem to convert it into 16F1615. Do not work for me CLC does not have the signals on RC4, I do not know why ?? I am doing something wrong but what ?? Running program 16F1509. // CONFIG1 #pragma config FOSC = INTOSC // Oscillator Selection Bits->INTOSC oscillator: I/O function on CLKIN pin #pragma config WDTE = OFF // Watchdog Timer Enable->WDT disabled #pragma config PWRTE = OFF // Power-up Timer Enable->PWRT disabled #pragma config MCLRE = OFF // MCLR Pin Function Select->MCLR/VPP pin function is digital input #pragma config CP = OFF // Flash Program Memory Code Protection->Program memory code protection is disabled #pragma config BOREN = ON // Brown-out Reset Enable->Brown-out Reset enabled #pragma config CLKOUTEN = OFF // Clock Out Enable->CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin #pragma config IESO = ON // Internal/External Switchover Mode->Internal/External Switchover Mode is enabled #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled // CONFIG2 #pragma config WRT = OFF // Flash Memory Self-Write Protection->Write protection off #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable->Stack Overflow or Underflow will cause a Reset #pragma config BORV = LO // Brown-out Reset Voltage Selection->Brown-out Reset Voltage (Vbor), low trip point selected. #pragma config LPBOR = OFF // Low-Power Brown Out Reset->Low-Power BOR is disabled #pragma config LVP = OFF // Low-Voltage Programming Enable->Low-voltage programming enabled #define _XTAL_FREQ 16000000 #include //#include //#include #include void main(void) { OSCCONbits.IRCF = 0b1111; // 16 MHz OSCCONbits.SCS = 0b00; // Clock determined by FOSC<2:0> in config LATA = 0x00; LATB = 0x00; LATC = 0x00; /** TRISx registers */ TRISA = 0b00000000; TRISB = 0b00000000; //TRISC = 0xEF; /** ANSELx registers */ ANSELA = 0b00000000; // zera to I/0, 1 to analog ANSELB = 0b00000000; // zera to I/0, 1 to analog ANSELC = 0b00000000; // zera to I/0, 1 to analog /** WPUx registers */ WPUA = 0b00000000; //rezys podci do plusa 1-enable 0-disabled WPUB = 0b00000000; //rezys podci do plusa 1-enable 0-disabled OPTION_REGbits.nWPUEN = 0; /** APFCONx registers */ APFCON = 0x00; CM1CON0 = 0b00000000; //kompalatory wyl uint8_t j; //**************************************************************************** CLC2GLS0 = 0x20; CLC2GLS1 = 0x00; CLC2GLS2 = 0x00; CLC2GLS3 = 0x00; CLC2SEL0 = 0x00; CLC2SEL1 = 0x06; CLC2POL = 0x0E; CLC2CON = 0x82; // Register values as copied from CLC Designer Tool // PWM1 comes through CLC2 CLC4GLS0 = 0x02; CLC4GLS1 = 0xA4; CLC4GLS2 = 0x00; CLC4GLS3 = 0x90; CLC4SEL0 = 0x54; CLC4SEL1 = 0x05; CLC4POL = 0x0A; CLC4CON = 0xC5; // Adjust Timer2 period for desired baud rate // One bit period is two Timer2 periods T2CON = 0x04; PR2 = 2; // Adjust PWM1 duty cycle for desired "0" data-bit duty cycle // "1" data-bit duty cycle is automatically 50% PWM1CON = 0xE0; PWM1DCH = 1; PWM1DCL = 0x80; // MSSP configured for SPI master with Timer2_Period/2 clock, inverted clock SSP1CON1 = 0x33; // Output on RC4/CLC4 //TRISC &= 0xEF; TRISC = 0b00000000; //***************************************************************************** __delay_us(60); PIR1bits.SSP1IF = 1; while (1) { // __delay_us ( 100 ) ; for (j = 0; j < 200; ++j) { while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; // SSP1BUF = c; SSP1BUF = 255; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 0; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 0; } __delay_ms(300); for (j = 0; j < 200; ++j) { while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; // SSP1BUF = c; SSP1BUF = 0; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 255; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 0; } __delay_ms(500); for (j = 0; j < 200; ++j) { while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 255; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 255; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; SSP1BUF = 255; } __delay_ms(300); } } //****************************************************************************** Do not acting program 16F1615. // CONFIG1 #pragma config FOSC = INTOSC // Oscillator Selection Bits->INTOSC oscillator: I/O function on CLKIN pin #pragma config WDTE = OFF // Watchdog Timer Enable->WDT disabled #pragma config PWRTE = OFF // Power-up Timer Enable->PWRT disabled #pragma config MCLRE = OFF // MCLR Pin Function Select->MCLR/VPP pin function is digital input #pragma config CP = OFF // Flash Program Memory Code Protection->Program memory code protection is disabled #pragma config BOREN = ON // Brown-out Reset Enable->Brown-out Reset enabled #pragma config CLKOUTEN = OFF // Clock Out Enable->CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin #pragma config IESO = ON // Internal/External Switchover Mode->Internal/External Switchover Mode is enabled #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled // CONFIG2 #pragma config WRT = OFF // Flash Memory Self-Write Protection->Write protection off #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable->Stack Overflow or Underflow will cause a Reset #pragma config BORV = LO // Brown-out Reset Voltage Selection->Brown-out Reset Voltage (Vbor), low trip point selected. #pragma config LPBOR = OFF // Low-Power Brown Out Reset->Low-Power BOR is disabled #pragma config LVP = OFF // Low-Voltage Programming Enable->Low-voltage programming enabled #define _XTAL_FREQ 16000000 #include //#include //#include #include void main(void) { OSCCONbits.IRCF=0b1111; // 16 MHz OSCCONbits.SCS=0b00; // Clock determined by FOSC<2:0> in config LATA = 0x00; LATC = 0x00; /** TRISx registers */ TRISA = 0b00000000; //TRISC = 0xEF; /** ANSELx registers */ ANSELA=0b00000000; // zera to I/0, 1 to analog ANSELC=0b00000000; // zera to I/0, 1 to analog /** WPUx registers */ WPUA=0b00000000; //rezys podci do plusa 1-enable 0-disabled WPUC=0b00000000; //rezys podci do plusa 1-enable 0-disabled OPTION_REGbits.nWPUEN = 0; /** APFCONx registers */ //APFCON = 0x00; CM1CON0=0b00000000; //kompalator wyl CM2CON0=0b00000000; //kompalator wyl //ODx registers ODCONA = 0x00; ODCONC = 0x00; uint8_t j; //**************************************************************************** CLC2GLS0 = 0x20; CLC2GLS1 = 0x00; CLC2GLS2 = 0x00; CLC2GLS3 = 0x00; CLC2SEL0 = 0x00; CLC2SEL1 = 0x06; CLC2POL = 0x0E; CLC2CON = 0x82; // Register values as copied from CLC Designer Tool // PWM1 comes through CLC2 // LC4G1POL not_inverted; LC4G2POL inverted; LC4G3POL not_inverted; LC4G4POL inverted; LC4POL not_inverted; CLC4POL = 0x0A; // LC4D1S FOSC; CLC4SEL0 = 0x21; // LC4D2S CCP1 output; CLC4SEL1 = 0x0C; // LC4D3S SDO from MSSP; CLC4SEL2 = 0x28; // LC4D4S SCK from MSSP; CLC4SEL3 = 0x27; // LC4G1D3N disabled; LC4G1D2N disabled; LC4G1D4N disabled; LC4G1D1T enabled; LC4G1D3T disabled; LC4G1D2T disabled; LC4G1D4T disabled; LC4G1D1N disabled; CLC4GLS0 = 0x02; // LC4G2D2N enabled; LC4G2D1N disabled; LC4G2D4N disabled; LC4G2D3N disabled; LC4G2D2T disabled; LC4G2D1T disabled; LC4G2D4T enabled; LC4G2D3T enabled; CLC4GLS1 = 0xA4; // LC4G3D1N disabled; LC4G3D2N disabled; LC4G3D3N disabled; LC4G3D4N disabled; LC4G3D1T disabled; LC4G3D2T disabled; LC4G3D3T disabled; LC4G3D4T disabled; CLC4GLS2 = 0x00; // LC4G4D1N disabled; LC4G4D2N disabled; LC4G4D3N enabled; LC4G4D4N disabled; LC4G4D1T disabled; LC4G4D2T disabled; LC4G4D3T disabled; LC4G4D4T enabled; CLC4GLS3 = 0x90; CLC4CON = 0xC5; // Adjust Timer2 period for desired baud rate // One bit period is two Timer2 periods T2CON = 0x04; PR2 = 2; // Adjust PWM1 duty cycle for desired "0" data-bit duty cycle // "1" data-bit duty cycle is automatically 50% CCP1CON = 0x8F; CCPR1H = 1; CCPR1L = 0x80; PWM3CON = 0xE0; PWM3DCH = 1; PWM3DCL = 0x80; //bool state = GIE; GIE = 0; PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x00; // unlock PPS RC4PPS = 0x07; //RC4->CLC4:CLC4OUT; PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x01; // lock PPS //GIE = state; // MSSP configured for SPI master with Timer2_Period/2 clock, inverted clock SSP1CON1 = 0x33; // Output on RC4/CLC4 TRISC &= 0xEF; //TRISC=0b00000000; //***************************************************************************** __delay_us ( 60 ) ; PIR1bits.SSP1IF = 1; while(1) { // __delay_us ( 100 ) ; for (j = 0; j < 200; ++j) { while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF = 0; // SSP1BUF = c; SSP1BUF=255; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF =0; SSP1BUF=0; while (!PIR1bits.SSP1IF); PIR1bits.SSP1IF =0; SSP1BUF=0; } } } [attachment=16F1615_CLC.ZIP ] Attachment(s) 16F1615_CLC.ZIP (162.43 KB) - downloaded 14 times |
|
相关推荐
2个回答
|
|
RC4PPS=0x07;//RC4->CLC4:CLC4OUT;在161F1615数据表中,没有选项将LC4输出到RC4。如果需要i/o的输入,必须使用CLCxPPS。
以上来自于百度翻译 以下为原文 RC4PPS = 0x07; //RC4->CLC4:CLC4OUT; In the 16F1615 datasheet, no option for LC4 out to RC4. If you want input from i/o you have to use CLCxPPS. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
775浏览 1评论
665浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
593浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
675浏览 0评论
575浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 21:03 , Processed in 1.480753 second(s), Total 79, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号