完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
因此,我有一堆指令,用于控制输出输出驱动LED的LateD,以及端口B的输入。我扩展了代码和布线以适应端口A和C,PIC刚刚停止响应。我在任何时候只有4个LED,所以我怀疑这是一个电源问题。我所有的连接似乎都很好,我的10K上拉都很好,LED和限流电阻很好,等等。所以我把代码往下拆,然后再往下拆,这样它下面就是这样,它仍然没有响应。我甚至尝试了另一个芯片。我有一种感觉,我只是忽略了一些简单的东西…但是我使用了PICIT 3,MPLAB X IDE 3.26,高科技VS 1.36,包括& lt;S.RD0=0;//输出TrdBITS.RD1=0;//不使用RB6、RB7和Re3;(1){(PotocButs.RC4==0)/ /好{{LaDD}.LATD1=1;LADDITS.LATD2=1;} {{LaDD}.LaDd1= 0;LabdBist.LaDd2= 0;}} / / Hees;SDBITdlb.h & gt;.lc.h & gt;*包含“CONFIG.H”//主头文件包含列出的所有例程的定义。AdCON0= 0x00;ANSELB=0x00;ANSELC= 0x00;ANSELD=0x00;ANSELE=0x00;//建议将所有未使用的端口设置为输出,并将它们的//值设置为0x00(在下一个代码块中)。TrISA=0x00;TrISB= 0x00;TrISC= 0x00;TrISD= 0x00;TrISE=0x00;//至起始根据芯片的建议,我把它们全部清理干净。//为每个I/O端口清除所有端口和锁存值。PATA= 0x00;LATA= 0x00;LATB= 0x00;PORTC=0x00;LATC= 0x00;PARD= 0x00;Posie= 0x00;迟到=0x00;} //配置位配置。HμiIFNDEF CONFIXHY定义了CONtiGH//PIC18F46K22配置位设置//C’源代码配置语句。{ PraceMang-COMPIG-COFIG-IOSO=O/O///CON2L L·PrAPMA配置,PWRTEN= OF//OXY-PracMA配置文件BRON=SBODIS//OXY Primamatlab配置BRV=285 ///2O2H2Prima配置文件WDTEN=SWON//OXY-PrAPMA配置文件WDTPS=32768 ////Orth3H*在/ /G T3CMX= PARD02//XORY-PARDMA2/CONMIGRIGM配置,MCLRe= ExtMCLR//OXY-PRADMA配置,STVRUN=O//YAX-PRAGMA配置,LVP= OF//OXY-PracMA配置,XST= OF//OXY-PRAGMA配置,CP0= OF//A,PARMICAM配置,CP1= OF//A,Pr2= OF//A,Pr3/OF/P = ON//γCOPFIG-Prima-PrimaCopIg CPD= Off//PyrApTracMA配置文件WRT0= OF//OXY-PRAGMA配置符WRT1= OF//OXY-PRAGMA配置文件WRT2OF//OXY-PRAQMA配置WRT3=O///CONT66H*拉格马#pragma配置EBTR1=OFF//#pragma配置EBTR2=OFF//#pragma配置EBTR3=OFF//T//CONFIG7H#pragma配置EBTRB=OFF//#endif/*CON._H*/
以上来自于百度翻译 以下为原文 So I had a bunch of instructions for controlling out puts driving LEDs on Lat D, and the inputs on Port B. I expanded the code and the wiring to accommodate ports A and C, and the the PIC just stopped responding. I only had 4 LEDS on at any one moment, so I doubt it was a power issue. All my connections seemed good, my 10K pullups were fine, LEDs and current limiting resistors good, etc. So I stripped the code back down, and then down some more so its like this below and its still non responsive. I even tried another chip. I have a feeling I am just overlooking something simple...but I am stuck. Im using Pickit 3, MPLAB X IDE 3.26, Hi-Tech Vs 1.36 #include #include #include void main(void) { TRISCbits.RC4 = 1; // Input //TRISBbits.RB6 = 1; // PGC //TRISBbits.RB7 = 1; // PGD TRISDbits.RD0 = 0; // Output TRISDbits.RD1 = 0; // Output //DONT USE RB6, RB7, and RE3 while (1) { if (PORTCbits.RC4==0) //GOOD { LATDbits.LATD1 = 1; LATDbits.LATD2 = 1; } else { LATDbits.LATD1 = 0; LATDbits.LATD2 = 0; } } } //Heres the main.c file for the project #include #include #include #include "config.h" //The main header file contains the definitions for all of the routines listed. #include "main.h" void setup(void) { //Make sure ADC module does not interfere with IO by disabling them. ADCON0 = 0x00; ANSELA = 0x00; ANSELB = 0x00; ANSELC = 0x00; ANSELD = 0x00; ANSELE = 0x00; //It is recommended to set all unused ports to output and to set their //values to 0x00 (which is done in the next code block.) TRISA = 0x00; TRISB = 0x00; TRISC = 0x00; TRISD = 0x00; TRISE = 0x00; // To initialize the chip, and per recommendations, I am clearing them all. //Clearing all of port and latch values for each I/O port. PORTA = 0x00; LATA = 0x00; PORTB = 0x00; LATB = 0x00; PORTC = 0x00; LATC = 0x00; PORTD = 0x00; LATD = 0x00; PORTE = 0x00; LATE = 0x00; } //Configuration bits config.h #ifndef CONFIG_H #define CONFIG_H // PIC18F46K22 Configuration Bit Settings // 'C' source line config statements #pragma config PRICLKEN = ON // #pragma config FCMEN = OFF // #pragma config IESO = OFF // // CONFIG2L #pragma config PWRTEN = OFF // #pragma config BOREN = SBORDIS // #pragma config BORV = 285 // // CONFIG2H #pragma config WDTEN = SWON // #pragma config WDTPS = 32768 // // CONFIG3H #pragma config PBADEN = OFF // #pragma config HFOFST = ON // #pragma config T3CMX = PORTC0 // #pragma config P2BMX = PORTD2 // #pragma config MCLRE = EXTMCLR // #pragma config STVREN = ON // #pragma config LVP = OFF // #pragma config XINST = OFF // #pragma config CP0 = OFF // #pragma config CP1 = OFF // #pragma config CP2 = OFF // #pragma config CP3 = OFF // #pragma config CPB = OFF // #pragma config CPD = OFF // #pragma config WRT0 = OFF // #pragma config WRT1 = OFF // #pragma config WRT2 = OFF // #pragma config WRT3 = OFF // // CONFIG6H #pragma config WRTC = OFF // #pragma config WRTB = OFF // #pragma config WRTD = OFF // // CONFIG7L #pragma config EBTR0 = OFF // #pragma config EBTR1 = OFF // #pragma config EBTR2 = OFF // #pragma config EBTR3 = OFF // T // CONFIG7H #pragma config EBTRB = OFF // #endif /* CONFIG_H */ |
|
相关推荐
6个回答
|
|
对不起,我使用XC8 vs 1.35,而不是高科技1.35
以上来自于百度翻译 以下为原文 Sorry, im using XC8 vs 1.35, not hi-tech 1.35 |
|
|
|
所谓“不响应”,我假设你的意思是LED的输出不会改变,不管应用于引脚C4的逻辑电平的状态如何。对吗?嗯……我不知道你在你所发布的代码中调用SETUP()的位置。
以上来自于百度翻译 以下为原文 By "not responsive" I assume you mean that the LED outputs don't change regardless of the state of the logic level applied to pin C4. Right? Well... I don't see where you call setup() in the code that you posted. Regards, Dave |
|
|
|
准确地说,它们是低的。嗯…现在找那个。也许删除
以上来自于百度翻译 以下为原文 Exactly, they are stuck low. Hmm...looking for that now. Deleted perhaps |
|
|
|
|
|
|
|
而且,写信给波特和LATx都是毫无意义的。
以上来自于百度翻译 以下为原文 Also, it's pointless to write to both PORTx and LATx |
|
|
|
你的时钟源在运行吗?我没有看到配置中的FoC位的选择。也许我错过了?
以上来自于百度翻译 以下为原文 Is your clock source running? I do not see a selection for the FOSC bits in the configuration. Maybe I am missing it? |
|
|
|
只有小组成员才能发言,加入小组>>
4779 浏览 9 评论
1815 浏览 8 评论
1734 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2941 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2043 浏览 5 评论
423浏览 1评论
1101浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
345浏览 0评论
253浏览 0评论
LAN9252使用SQI通信,进行数字复位后读BYTE_TEST异常
1751浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-3-29 14:19 , Processed in 1.154432 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 深圳华秋电子有限公司
电子发烧友 (电路图) 粤公网安备 44030402000349 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号