完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在过去的几个小时里,我一直在思考这个问题,但是我的大脑却无法理解如何用BTFSC命令读取PIN。我在C中写所有的东西,但是需要一个非常快的函数,所以我想我写了一个小的ASM片段。代码将永远循环,只是复制引脚状态从一个引脚到另一个。就是这样。真的很容易。芯片:18F24k22这里我有:Pin_manager.h(只是重要部分)定义USB_TX_TRIS TRISC7\\\定义USB_TX_TX_TRIS_TRITRITRIS TRITRISC7\定义USB USB USB_TX_TRIX_TRIX_TRIX_Set.()定义USB_TX_TRISC7\\\\\\\\定义USB定义USB\\\#define USB_TX_Toggle()do{LATC7=~LATC7}同时(0)#定义USB_TX_XXXXXSetAnAnalog模式()PORTCbits.RC7#定义USB_TX_SetDiDigigigitalInInInput()定义USB_TX_XXXXXXXXXGetGetValValVal值()PORTCBRTCbits.USBCbits.USB_定义USB_XXXXXXX值()PORTCCXXXXXX值()PORTCCCBBBBBBBBXXX的USB.USB_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX#定义USB_TX_SetDigital.()do{ANSC7=0;}虽然(0)#定义SX_RX_RX_RX_RX_TRIX_TRIS TRITRISSSX_RX_RX_TRITRITRITRITRITRISB6#定义SX_RX_RX_RX_TRISXTRISXTRIXTRITRISB6#定义SX_SX_RX_RX_RX_TRIXTRITRISB6#定义SX_RX_RX_RX_LATX_LATB6#定义SX_LAXSX_LAX_LATX_LATB6#SX_LATX_LATXLATB6#定义SX_LAX_LAX_LATB6#定义SX_LA(0)#define SX_RX_GetValue()PORTBbit3.RB6#定义SX_RX_SetDigitalInput()DO{TRISB6=1; }同时在(0)#定义SX_RX_RX_SetDiGiGiGiGiGiGi数字Output()做{TRISB SX_RX_RX_Set数字_Set数字数字数字数字数字输入()做{SX_SX_SX_RX_Set数字数字数字_SetDiGiGiGiGiGiGiGiGiGiGiGiGitaInInput()做{{TRISBSB6=1;}}}}_同时在(0){{TRISBSBSBSBSB6=TRISB6=TRISB6=1;}}1;{1; {1; }}应该读取USB_T的当前值然后设置另一个引脚)#asm USB_SX_MODE:btfsc PORTCbits.RC7//USB_TX-这是没有工作的部分,编译器将错误发送到USB_TX_HIGH bcf LATB,6,c//SX_RX-我假设这会工作。我还没有测试过。GOTO UBSXSXMODESUBXTXYHO: BSF LATB,6,C//SXYRX -我假设这会起作用。我还没有测试过。goto USB_SX_MODE#endasmmain.c:140:error:(844)lexical errormain.c:140:error:(876)syntax errorI是100%肯定的,其格式为btfsc行。但对于我的生活,我找不到在线正确的语法……任何指针都会被赏识的。然后我终于可以睡着了……
以上来自于百度翻译 以下为原文 All Been fighting this for the last couple hours and my brain just can't wrap around how to read a pin with the btfsc command. I'm writing everything in c but need a very fast function so I figured I write a small asm snippet. the code will loop forever and just copy the pin status from one pin to another.. That's it. Really easy. Chip: 18F24k22 Here what I have: Pin_manager.h (just the important part) #define USB_TX_TRIS TRISC7 #define USB_TX_LAT LATC7 #define USB_TX_PORT PORTCbits.RC7 #define USB_TX_ANS ANSC7 #define USB_TX_SetHigh() do { LATC7 = 1; } while(0) #define USB_TX_SetLow() do { LATC7 = 0; } while(0) #define USB_TX_Toggle() do { LATC7 = ~LATC7; } while(0) #define USB_TX_GetValue() PORTCbits.RC7 #define USB_TX_SetDigitalInput() do { TRISC7 = 1; } while(0) #define USB_TX_SetDigitalOutput() do { TRISC7 = 0; } while(0) #define USB_TX_SetAnalogMode() do { ANSC7 = 1; } while(0) #define USB_TX_SetDigitalMode() do { ANSC7 = 0; } while(0) #define SX_RX_TRIS TRISB6 #define SX_RX_LAT LATB6 #define SX_RX_PORT PORTBbits.RB6 #define SX_RX_WPU WPUB6 #define SX_RX_SetHigh() do { LATB6 = 1; } while(0) #define SX_RX_SetLow() do { LATB6 = 0; } while(0) #define SX_RX_Toggle() do { LATB6 = ~LATB6; } while(0) #define SX_RX_GetValue() PORTBbits.RB6 #define SX_RX_SetDigitalInput() do { TRISB6 = 1; } while(0) #define SX_RX_SetDigitalOutput() do { TRISB6 = 0; } while(0) #define SX_RX_SetPullup() do { WPUB6 = 1; } while(0) #define SX_RX_ResetPullup() do { WPUB6 = 0; } while(0) main.c (just a small part that should read the current value of USB_TX and set another pin) #asm USB_SX_MODE: btfsc PORTCbits.RC7 //USB_TX - This is the part not working, compiler throws error goto USB_TX_HIGH bcf LATB, 6, c //SX_RX - I'm assuming this will work. I haven't tested yet. goto USB_SX_MODE USB_TX_HIGH: bsf LATB, 6, c //SX_RX - I'm assuming this will work. I haven't tested yet. goto USB_SX_MODE #endasm main.c:140: error: (844) lexical error main.c:140: error: (876) syntax error I'm 100% positive its the format of the btfsc line. but for the life of me, I can't find online the right syntax... Any pointers would be appreciated. Then I can finally go to sleep... Thanks Damon |
|
相关推荐
4个回答
|
|
不能用ASM的名称访问BITFEAR结构。
以上来自于百度翻译 以下为原文 You can't access bitfield structures by name from asm. Try: USB_SX_MODE: btfsc PORTC,7,c ;USB_TX goto USB_TX_HIGH bcf LATB, 6,c ;SX_RX goto USB_SX_MODE USB_TX_HIGH: bsf LATB, 6,c ;SX_RX goto USB_SX_MODE or better still: USB_SX_MODE: btfsc PORTC,7,c ;USB_TX bsf LATB, 6,c ;SX_RX btfss PORTC,7,c ;USB_TX bcf LATB, 6,c ;SX_RX goto USB_SX_MODE |
|
|
|
它就在PIC18F24K22数据表的第386页,在“指令集”章节中。
以上来自于百度翻译 以下为原文 It's right there on page 386 of the PIC 18F24K22 datasheet, in the "instruction set" chapter. |
|
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5195 浏览 9 评论
2013 浏览 8 评论
1937 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3185 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2240 浏览 5 评论
751浏览 1评论
637浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
522浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
648浏览 0评论
549浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-2 19:15 , Processed in 1.508973 second(s), Total 84, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号