完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好。我正在努力理解它是如何工作的。我使用内部时钟源4 MHz来产生不同长度的延迟。在MLAB X IDE TMR0工作中,我看到逻辑分析仪MPLAB中的延迟。但是,当我编程硬件设备时,我在数字示波器上什么也看不见。我做了什么错事?
以上来自于百度翻译 以下为原文 Hello. I'm trying to understand how it works. I use internal clock sourse 4 MHz to generate delay of different lengths. In the MLAB X IDE TMR0 work, and i see delay in the logic analyzer MPLAB. But when i programm my hardware device, i don't see nothing on the digital oscilloscope. What have I do wrong? #pragma config FOSC = INTOSCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR) #pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled) #pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) #include void Timer_Init() { TMR0IE = 1; INTCONbits.T0IE = 1; GIE = 1; OPTION_REGbits.T0CS = 0; OPTION_REGbits.T0SE = 0; OPTION_REGbits.PSA = 0; OPTION_REGbits.PS2 = 0; OPTION_REGbits.PS1 = 0; OPTION_REGbits.PS0 = 0; } void interrupt isr() { if(TMR0IF == 1) { TMR0 = 101; RA1 =~ RA1; INTCONbits.T0IF = 0; } } void main(void) { TRISA1 = 0; RA1 = 1; TMR0 = 100; Timer_Init(); while(1); } |
|
相关推荐
10个回答
|
|
你的程序真的在硬件上运行吗?尝试运行调试生成并确保它实际工作吗?什么是“TMR0IE”和“TMR0IF”?我在数据表中找不到它们(但我可以看到t0IE和t0IF)。苏珊
以上来自于百度翻译 以下为原文 Is your program running at all on the real hardware? Try running a debug build and making sure that it is actually working? What are 'TMR0IE' and 'TMR0IF'? I can't find them in the data sheet (but I can see the 'T0IE' and 'T0IF' bits in INTCON). Susan |
|
|
|
它们被定义在PIC16F628HSO中,XC8的作者由于某种原因允许两种形式…
以上来自于百度翻译 以下为原文 They are defined in pic16f628.h so the XC8 authors are allowing for both forms for some reason... |
|
|
|
RA1默认为必须禁用的模拟函数,以便将其用于数字I/O.
以上来自于百度翻译 以下为原文 RA1 defaults to analog function that must be disabled in order to use it for digital I/O. |
|
|
|
是的,其他程序工作。所有引脚具有数据方向位(TIS寄存器),可以配置这些引脚作为输入或输出。
以上来自于百度翻译 以下为原文 yes, other programm work. All pins have data direction bits (TRIS registers) which can configure these pins as input or output. TRISA1 = 0; |
|
|
|
所有引脚都有数据方向位(TIS寄存器),它可以将这些引脚配置为输入或输出。您的代码将读取一个“0”,将其补充为“1”,并将其写入RA1。所以RA1总是被设置的。
以上来自于百度翻译 以下为原文 All pins have data direction bits (TRIS registers) which can configure these pins as input or output. TRISA1 = 0; A pin that is analog will read as zero. Your code RA1 =~ RA1; will read a '0', complement it to a '1' and write it to RA1. So RA1 will ALWAYS be set. |
|
|
|
TIS不禁用模拟。启用模拟使端口读取的引脚总是为0。因为你读了PIN,写回逆,你总是写1回到RA1。禁用RA1的模拟。把我揍一顿
以上来自于百度翻译 以下为原文 TRIS does not disable analog. Analog enabled causes a port read of the pin to always be 0. Since you read the pin and write back the inverse you are always writing a 1 back to RA1. Disable analog for RA1. - beat me to it |
|
|
|
|
|
|
|
比较器默认使用RA0RA3作为模拟输入。数据表图10-1显示了配置和引脚是模拟(A)还是数字(D)。将CMCON设置为0x07将RA0-RA3设置为数字模式。
以上来自于百度翻译 以下为原文 The comparators defaults to using RA0-RA3 as analog inputs. Datasheet figure 10-1 shows the configurations and whether the pins are analog (A) or digital (D). Setting CMCON to 0x07 will set RA0 - RA3 to digital mode. |
|
|
|
|
|
|
|
它是-CMCon=0x07?是的。在PIC16F628 A数据表中读取“5.1端口和TrISA寄存器”,并特别研究“示例5-1:初始化PORTA”。
以上来自于百度翻译 以下为原文 it is - CMCON = 0x07 ? yes. Read "5.1 PORTA and TRISA Registers" in the PIC16F628A datasheet, and particularly study "EXAMPLE 5-1: INITIALIZING PORTA" |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 06:17 , Processed in 1.412329 second(s), Total 97, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号