完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我有一个问题与我的程序的22 sLoc(标题建议)。我所面临的问题是输出微弱的闪光,而不是切换。这可能是一个权力问题,但我怀疑。代码的问题部分是完全封闭的,应该是简单的修复。代码段是用来检查RXPIN是否低,如果是,它应该确保它的时间是2 ^ 16指令周期长或更长。一旦确定它足够长,程序就切换TXPIN,然后等待2 ^ 16秒长。为了确保在RXPIN上接收的信号不是多个信号,它将在255个或更多个指令周期的间隙之后重置计数。所有连接都是正确连接的,所有常量都被定义了。程序编译正确。当这个代码段运行时,PIC比它通常所处的温度高出几度。TMP0、TMP1、TMP2和TMP3常量引用RAM中的位置,并且是绝对可访问的。源代码流Curvitimes由于Survivs.不可用。我也很乐意提供任何额外的信息来解决这个问题。
以上来自于百度翻译 以下为原文 Hello, I am having an issue with 22 SLOC of my program (as the title suggests). The issue I am having is the output dimly flashes rather than toggles. It might be a power issue, but I doubt it. The problematic section of code is fully enclosed and should be simple to fix. The snippet is meant to check if RXPIN is low and if it is it should make sure the time it is low is 2^16 instruction cycles long or longer. Once it makes sure it is long enough the program toggles TXPIN then waits for 2^16 seconds long. To make sure the signal received on RXPIN isn't multiple signals it will reset the count after a gap of 255 or greater instruction cycles. Additional Information The MCU I am using is a PIC12f509. All connections are definitely properly connected and all constants are defined. The program compiles properly. The PIC wARMs up to a couple degrees higher than it usually sits at when this code section is running. The TMP0, TMP1, TMP2 and TMP3 constants refer to locations in RAM and are definitely accessible. Source code rx BTFSC GPIO, RXPIN ; Check if a signal is detected. GOTO rxoff ; Nope, jump to rxoff. CLRF TMP3 ; Clear the off register because the gap was false. ; 2^16 us delay. INCFSZ TMP0 ; Yes, count up the minor register, skip return if overflow. GOTO rx ; Go back so we can keep counting. INCFSZ TMP1 ; Minor register overflowed, so count major one. Skip return if overflow. GOTO rx ; Return so we can keep counting. ; Toggle TXPIN. BTFSS GPIO, TXPIN BSF GPIO, TXPIN BCF GPIO, TXPIN ; Delay before we continue. rxafter INCFSZ TMP0 ; Increase TMP0, skip if overflow. GOTO rxafter ; Keep counting. INCFSZ TMP1 ; Increase TMP1, skip if overflow GOTO rxafter ; Keep counting. GOTO rx ; Start again. rxoff INCFSZ TMP3 ; Increase a temporary register, skip if overflow. GOTO rx ; Go back for recount. ; Temporary register overflowed. CLRF TMP0 ; Clear temporary register. CLRF TMP1 ; Clear other temporary register. GOTO rx ; Go back to listen again. Flowchart Image not available due to issues. PS: Sorry for any bad code formatting, there is no assembly highlighting option. I am also more than happy to provide any additional information required to solve this issue. |
|
相关推荐
17个回答
|
|
|
|
|
|
PrHAPPSHTPS://E.WiKiTo.Org/Wik/SooSeCier-LeSeSufOf码
以上来自于百度翻译 以下为原文 Perhaps https://en.wikipedia.org/wiki/Source_lines_of_code |
|
|
|
可能是指“22源代码行”。首字母缩写词有时是一种真正的痛苦。
以上来自于百度翻译 以下为原文 Probably refering to "22 Source Lines Of Code". Acronyms are sometimes a real pain..... |
|
|
|
这可能是一个RMW(读修改写)问题,在您的写入GPIO pins.RMW(读修改写)问题解释DRMW和解决方案,因为它没有显示您的所有代码,也可以写入其他GPIO引脚。移动到一个新的PIC与LAT寄存器WOULD解决这个问题,否则你需要一些防御编程技术。
以上来自于百度翻译 以下为原文 This could be a RMW (read-modify-write) issue on your writes to the GPIO pins. Hard to tell because you did not show all the rest of your code, which could also be writing to other GPIO pins. Moving to a newer PIC with a LAT register would fix that problem, otherwise you need some defensive programming techniques. |
|
|
|
什么是GPIO引脚和如何?BTFSS GPIO指令读取引脚,如果它保持低(或高),因为引脚上的负载(LED可能?)它可能无法读取上次发送给它的状态。
以上来自于百度翻译 以下为原文 WHat is conected to the GPIO pin and how? The BTFSS GPIO instruction reads the pin, if it is held low (or high) because of the load on the pin (an LED maybe?) it may not read the state you last sent to it. |
|
|
|
也许试着用这个代替这个
以上来自于百度翻译 以下为原文 Perhaps try replacing this ; Toggle TXPIN. BTFSS GPIO, TXPIN BSF GPIO, TXPIN BCF GPIO, TXPIN with this ; Toggle TXPIN. movlw 1 << TXPIN xorwf GPIO |
|
|
|
|
|
|
|
对不起,最近的答复。TXPIN被分配为PIN 3(GP4),并作为输出三态。它连接到一个LED。最初,我用GPIO寄存器将工作寄存器(与TXPIN集对应的位)xxx,以切换它。这也显示了问题。所提供的代码的部分没有退出,所以在运行段时没有其他GPIO修改。我尝试使用IO写的影子寄存器。此方法在启动时导致闪存,然后不再输出。
以上来自于百度翻译 以下为原文 Sorry for the late reply. The TXPIN is allocated as pin 3 (GP4) and is tristated as an output. It is connected to an LED. Originally I XORed the working register (which had the bit that corresponded with TXPIN set) with the GPIO register to toggle it. This also exhibited the issue. The section of the code provided is not exited, so no other GPIO modifications can occur while the segment is running. I've attempted to use a shadow register for the IO writes. This method causes a flash at startup then no more output. |
|
|
|
显示你使用的代码,你可能没有正确地完成它。
以上来自于百度翻译 以下为原文 Show the code you used. You may just not have done it correctly. |
|
|
|
显示您使用的代码。您可能只是没有正确地完成它。显示所有代码(配置寄存器,一切),而不仅仅是您认为有问题的部分。问题很可能是代码中的其他地方…
以上来自于百度翻译 以下为原文 Show the code you used. You may just not have done it correctly. Show ALL the code (configuration registers, everything), not just the part you think has the issues. It is likely the issue is somewhere else in your code.... |
|
|
|
这里是整个程序(使用影子寄存器方法可能不正确)。任何坏格式都是因为MPLAB对我复制代码疯狂。
以上来自于百度翻译 以下为原文 Here's the entirety of the program (using the shadow register method that may be incorrect). org 0x000 __CONFIG 0x12 TXPIN EQU 0x04 RXPIN EQU 0x01 VPIN EQU 0x05 BUTTON EQU 0x00 GPIO EQU 0x06 TMP0 EQU 0x07 TMP1 EQU 0x08 TMP2 EQU 0x09 TMP3 EQU 0x0A GPIOS EQU 0x0B RESET CODE 0x000 setup ; Clear the temporary registers to ensure they are ready for use. CLRF TMP0 CLRF TMP1 CLRF TMP2 CLRF TMP3 ; Clear option register. MOVLW 0x00 OPTION BCF TMP0, TXPIN ; Set TXPIN as an output. BSF TMP0, RXPIN ; Set RXPIN as an input. BSF TMP0, BUTTON ; Set BUTTON as an input. BSF TMP0, VPIN ; Set VPIN as an input. MOVF TMP0 ; Load what we just defined. TRIS GPIO ; Set pinstates. CLRF GPIO CLRF TMP0 ; Clear the temporary register for use in rx and tx. BTFSC GPIO, VPIN ; Get VPIN state. GOTO rx ; If VPIN is HIGH receive. GOTO tx ; If VPIN is LOW transmit. ; Transmission stuff. send ; send sends a 65536 us (65.5 ms) signal. MOVLW 0x14 MOVWF TMP0 CLRF TMP1 send_loop DECFSZ TMP0 GOTO send_sub RETLW 0 send_sub BSF GPIO, TXPIN NOP NOP NOP NOP BCF GPIO, TXPIN NOP NOP NOP NOP NOP DECFSZ TMP1 GOTO send_sub GOTO send_loop tx BTFSS GPIO, BUTTON ; Check if button is pressed. GOTO tx ; Not pressed. CALL send ; Pressed, call send (send takes a long time so no debouncing is required). CLRF GPIO CLRF TMP0 CLRF TMP1 MOVLW 0x03 MOVWF TMP2 txwait DECFSZ TMP0 GOTO txwait DECFSZ TMP1 GOTO txwait DECFSZ TMP2 GOTO txwait GOTO tx ; Go back to beginning. ; Receiving stuff. rx BTFSC GPIO, RXPIN ; Check if a signal is detected. GOTO rxoff ; Nope, jump to rxoff. CLRF TMP3 ; Clear the off register because the gap was false. ; 2^16 us delay. INCFSZ TMP0 ; Yes, count up the minor register, skip return if overflow. GOTO rx ; Go back so we can keep counting. INCFSZ TMP1 ; Minor register overflowed, so count major one. Skip return if overflow. GOTO rx ; Return so we can keep counting. ; Toggle TXPIN. BTFSS GPIOS, TXPIN BSF GPIOS, TXPIN BCF GPIOS, TXPIN MOVF GPIOS MOVWF GPIO ; Delay before we continue. rxafter INCFSZ TMP0 ; Increase TMP0, skip if overflow. GOTO rxafter ; Keep counting. INCFSZ TMP1 ; Increase TMP1, skip if overflow GOTO rxafter ; Keep counting. GOTO rx ; Start again. rxoff INCFSZ TMP3 ; Increase a temporary register, skip if overflow. GOTO rx ; Go back for recount. ; Temporary register overflowed. CLRF TMP0 ; Clear temporary register. CLRF TMP1 ; Clear other temporary register. GOTO rx ; Go back to listen again. END Any bad formatting is caused by MPLAB being mad at me copying the code. |
|
|
|
对于启动器,您应该在源代码中指定PIC设备,包括设备特定的包含文件& lt;p12f509.Inc & gt;使用包含在FieldFielePosits中的符号重写y-OngIfg行。
以上来自于百度翻译 以下为原文 For starter, you should
MOVF TMP0 ; Load what we just defined. TRIS GPIO ; Set pinstates with MOVF TMP0,W ; Load what we just defined. TRIS GPIO ; Set pinstates
; Toggle TXPIN. BTFSS GPIOS, TXPIN BSF GPIOS, TXPIN BCF GPIOS, TXPIN MOVF GPIOS MOVWF GPIO with ; Toggle TXPIN. MOVLW 1 << TXPIN XORWF GPIOS MOVF GPIOS,W MOVWF GPIO |
|
|
|
|
|
|
|
谢谢你,你的代码工作。感谢所有帮助过的人,这里的社区非常支持和帮助!
以上来自于百度翻译 以下为原文 Thank you 1and0, your code works. Thanks to everyone else who has helped, the community here is very supportive and helpful! |
|
|
|
你的代码应该在没有影子寄存器的情况下工作,因为你只有一个输出引脚。除非那个插销很重。
以上来自于百度翻译 以下为原文 Your code should had worked without a shadow register, because you have only one output pin. |
|
|
|
除非输出重载,因此不能达到真正的“1”。
以上来自于百度翻译 以下为原文 Unless the output is heavily loaded and thus cannot reach a true "1". |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5242 浏览 9 评论
2031 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3207 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2256 浏览 5 评论
778浏览 1评论
669浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
596浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
679浏览 0评论
577浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 23:04 , Processed in 1.544176 second(s), Total 108, Slave 92 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号