完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用MPLAB IDE V891,我已经为PIC16F630编写了一个程序来在PORTC上产生PWM输出。在PATRA-RA0、RA1、RA4和RA5上有四个输入,其中有源输入为低电平。我使用的是4MHz内部振荡器。我有一个问题,使用MPLAB SIM。我应该说,我已经成功地为PIC12F629制作了一个类似的程序。我的问题涉及RA4,它似乎不需要输入。我的初始化代码如下:init BSF状态,RP0;Bank 1调用3FFH;获得校准信息MOVWF OSCCAL;设置内部振荡器;到4MHz MOVLW B’00 110011';在PORTA MOVWF TrISA MOVLW B′00000000′上输入4个;PORTC是输出MOVWF tiSISC MOVLW B’00 1100100';在变更MOVWF IOCA上;对于RA0、RA1、RA4、RA5 MOVLW B′00000 101′;为TMR0 MOVWF OpTythReg设置预分频器;到1/64 BCF OpTythReg,T0CS;将TMR0设置为内部时钟BCF状态,RP0;银行0 MOVLW B’1000 1000’MOVWF ITCN;使全局和端口中断MOVLW B’00000 111’;FF比较器MOVWF CMCONI当我运行MPLAB SIM RA0,RA1和RA5响应,但没有发生RA4。另一个奇怪的特征是,当使用手表观察寄存器时,波尔塔在输入被施加时不发生变化-应该观察记录这样的变化吗?
以上来自于百度翻译 以下为原文 I am using MPLAB IDE v8.91 and I have written a program for a PIC16F630 to generate a pwm output on PORTC. There are four inputs on PORTA - RA0, RA1, RA4 and RA5 with an active input being a LOW. I am using the 4MHz internal oscillator. I am having a problem using MPLAB SIM. I should say that I have successfully produced a similar program for a PIC12F629. My problem concerns RA4 which does not seem to repond to an input. My initialisation code is as follows: Init bsf STATUS,RP0 ;bank 1 call 3FFh ;get calibration info movwf OSCCAL ;set up internal oscillator ;to 4MHz movlw b'00110011' ;4 inputs on PORTA movwf TRISA movlw b'00000000' ;PORTC are outputs movwf TRISC movlw b'00110011' ;interrupt-on-change movwf IOCA ;for RA0,RA1,RA4,RA5 movlw b'00000101' ;set prescaler for TMR0 movwf OPTION_REG ;to 1/64 bcf OPTION_REG,T0CS ;set TMR0 to internal clock bcf STATUS,RP0 ;bank 0 movlw b'10001000' movwf INTCON ;enable global and PORTA interrupts movlw b'00000111' ;turn off comparators movwf CMCON When I run MPLAB SIM RA0, RA1 and RA5 respond but nothing happens for RA4. Another odd feature is that when using WATCH to observe the registers, PORTA does not appear to change when inputs are applied - should WATCH record such changes? Attachment(s) motor controller-6V.asm (10.08 KB) - downloaded 38 times |
|
相关推荐
3个回答
|
|
|
|
|
|
+ 1你的配置设置可以停止RA4工作。我似乎记得模拟器可能有一个错误与PIC16F630,对待它像PIC16F67,它有一个安塞尔寄存器。尝试清理安塞尔,看看这是否修复模拟器问题。它不会在真正的PIC16F630中产生任何差异(安塞尔在地址0x91,它是BANG-1中的偏移0x11)
以上来自于百度翻译 以下为原文 +1 Your config settings could stop RA4 working. I seem to remember the Simulator may have a bug with the PIC16F630, treating it like a PIC16F676 that has an ANSEL register. Try clearing ANSEL and see if that fixes the simulator problem. It won't make any difference in a real PIC16F630, (ANSEL is at address 0x91, which is offset 0x11 in Bank-1) |
|
|
|
这里是配置,从下载的ASM文件:CKOUT是RA4,这也是AN3。那肯定会引起问题。
以上来自于百度翻译 以下为原文 Here is the CONFIG, from the downloaded ASM file: __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT The CLKOUT is on RA4, which is also AN3. That would definitely cause a problem. |
|
|
|
只有小组成员才能发言,加入小组>>
5284 浏览 9 评论
2056 浏览 8 评论
1968 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3231 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2277 浏览 5 评论
820浏览 1评论
709浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
652浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
605浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-12 08:53 , Processed in 1.246477 second(s), Total 81, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号