完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
有人会协助我的4阶段if语句的逻辑。它基本上执行四组中的一组,具体取决于如何设置2个拨码开关。问题是,无论我如何设置2个拨码开关,它总是转到868行(见附件)。无论我如何设置外部拨码开关,我都无法前往859,862或865行。我已经监控了dip开关,它们在3.3V或0V逻辑电平下运行正常,具体取决于倾角位置。将1个接口浸入PA2,将2个接口浸入PC5。
也许我没有设置正确的括号,或者我的中心&需要&&amp ;?也许是我!是不是正确的操作数?我甚至尝试了根据839-855行的不同方法,但这并不是全部工作,即在设置841,845,850或854的断点之后,它从未停止过。 以上来自于谷歌翻译 以下为原文 Would someone assist with the logic of my 4 stage if-statement. It basically performs one of four groups depending upon how 2 dip switches are set. The problem is that no matter how I set the 2 dip switches it always goes to line 868 (see attachment). I can never get it to go to line 859, 862, or 865, no matter how I set the external dip switches. I have monitored the dip switches and they are functioning properly as a 3.3V or 0V logic level, depending upon dip position. Dip 1 interfaces to PA2, and dip 2 interfaces to PC5. Maybe I don't have my parenthesis set correct, or maybe my center & needs to be &&? Perhaps my ! is not the correct operand? I even tried a different approach as per line 839-855, but that didn't work AT ALL, i.e., after setting breakpoints at 841,845,850,or 854, it never stopped. |
|
相关推荐
8个回答
|
|
你好,伊恩,
感谢您的答复。我已经为每行157_158初始化了PA2和PC5。见附件。 无法联系退回,因为我只在程序未运行时设置它们。 我改变了&和&&amp ;. 无论拨码开关设置如何,程序仍然始终在第869行停止。见附件。我的dip开关高压线连接到3.3V,另一个连接到IO。上次我在ST72F264中实现了这一点,几年前我也没有使用过一些下拉电阻,没有这些问题,但是当我测量IO的电压时,它是3.3V的地面接地。 我甚至尝试添加第854_855_857行显示的代码,但它没有帮助,因此我将其注释掉。 你能告诉我将实现的代码:''带有变量的GPIOx语句,每个开关一个,然后使用调试器将变量设置为0和1(在正确的位位置)。'' 但是,我对STM8L做了很多工作:RTC,2个比较器,内部参考,I2C,SPI,许多IO作为输出(高和低),没有LCD,但我不知道PA2和PC5可能会发生冲突别的。 以上来自于谷歌翻译 以下为原文 Hello Ian, Thanks for your response. I have initialized PA2 and PC5 per line157_158. See attachment. Contact bounce is not possible because I only set them when the program is notrunning. I changed & to &&. No matter what the dip switch settings, the program still always stops at line869. See attachment. I have the dip switch high line attached to3.3V and the other to the IO. Last time I implemented this in ST72F264 Iused some pull down resistors too some years ago without these kinds ofproblems, but when I measure the voltage at the IO it is either 3.3V oressentially ground. I even tried adding code shown at line 854_855_857, but it doesn't help so Icomment it out. Would you show me the code that will implement: ''GPIOx statementswith variables, one per switch and then use the debugger to set the variablesto 0 and 1 (in the correct bit position).'' However, I am doing a lot with the STM8L: RTC, 2 comparators, internalref, I2C, SPI, lots of IO's as outputs (high and low), no LCD, but I don't seehow PA2 and PC5 can possibly be conflicting with something else. |
|
|
|
你好,伊恩,
感谢您的答复。我已经为每行157_158初始化了PA2和PC5。见附件。 无法联系退回,因为我只在程序未运行时设置它们。 我改变了&和&&amp ;. 无论拨码开关设置如何,程序仍然始终在第869行停止。见附件。我的dip开关高压线连接到3.3V,另一个连接到IO。上次我在ST72F264中实现了这一点,几年前我也没有使用过一些下拉电阻,没有这些问题,但是当我测量IO的电压时,它是3.3V的地面接地。 我甚至尝试添加第854_855_857行显示的代码,但它没有帮助,因此我将其注释掉。 你能告诉我将实现的代码:''带有变量的GPIOx语句,每个开关一个,然后使用调试器将变量设置为0和1(在正确的位位置)。'' 但是,我对STM8L做了很多工作:RTC,2个比较器,内部参考,I2C,SPI,许多IO作为输出(高和低),没有LCD,但我不知道PA2和PC5可能会发生冲突别的。 以上来自于谷歌翻译 以下为原文 Hello Ian, Thanks for your response. I have initialized PA2 and PC5 per line157_158. See attachment. Contact bounce is not possible because I only set them when the program is notrunning. I changed & to &&. No matter what the dip switch settings, the program still always stops at line869. See attachment. I have the dip switch high line attached to3.3V and the other to the IO. Last time I implemented this in ST72F264 Iused some pull down resistors too some years ago without these kinds ofproblems, but when I measure the voltage at the IO it is either 3.3V oressentially ground. I even tried adding code shown at line 854_855_857, but it doesn't help so Icomment it out. Would you show me the code that will implement: ''GPIOx statementswith variables, one per switch and then use the debugger to set the variablesto 0 and 1 (in the correct bit position).'' However, I am doing a lot with the STM8L: RTC, 2 comparators, internalref, I2C, SPI, lots of IO's as outputs (high and low), no LCD, but I don't seehow PA2 and PC5 can possibly be conflicting with something else. |
|
|
|
你好,
是的,看起来PC5 / PA2的初始化是正确的,但是可能值得配置弱上拉或下降,只需要完全定义0和1等。看来正确的电平出现在芯片的引脚侧但是不在内部!值得检查PC5 / PA2是否与其他外围设备冲突或具有替代映射等。也可能值得尝试使用不同的已知工作端口引脚。 为了调试我的想法使用变量只是检查''if''代码而不是硬件。我的想法是将myIOTA定义为字节或无符号字符替换GPIOx-> IDR的出现。然后在调试器中,您可以将myPORTA设置为0x4以表示引脚PA2。 您的“if”逻辑可能还需要明确条件,因此: if(((GPIOA-> IDR& 4)== 1)&& ......等 希望有所帮助。 谢谢, 伊恩 以上来自于谷歌翻译 以下为原文 Hello, Yes it looks like PC5/PA2 are initialised correctly but it might be worth configuring for the weak pull-ups or downs, just to fully define 0 and 1 etc. It appears that the right levels are appearing on the pin side of the chip but not internally! It would be worth just checking that PC5/PA2 don't conflict with other peripherals or have alternative mappings etc. Might also be worth trying with different known working port pins. For debugging my idea to use variables is simply to check the ''if'' code as opposed to the hardware. The idea is to replace the occurrences of GPIOx->IDR with say myPORTA defined as a byte or unsigned char. Then in the debugger you can set myPORTA as 0x4 to represent pin PA2. Your ''if'' logic might also need to be explicit on the conditions, thus: if (((GPIOA->IDR & 4) == 1) && ... etc Hope that helps. Thanks, Ian |
|
|
|
我刚才发了一篇文章。你明白了吗?我没有看到它。 ST的系统令我感到沮丧:你会发现我两天前有一个双重帖子,因为它不会立即显示帖子或在你做出回复时将你注销,而不会告诉你。我几周前的第一次经历,因为这个问题,我发了两次。现在我太累了,今晚不再工作,而且很沮丧!!!
以上来自于谷歌翻译 以下为原文 I shared a post just now. Did you get it? I don't see it. ST's system is frustrating me: You'll see I have a double post from two days ago because it doesn't instantly show a post or logs you out when you are working on a response, without telling you. My very first experience a few weeks ago, I posted twice because of this issue. Now I'm too tired to work on this any longer tonight and frustrated!!! |
|
|
|
你好,
对不起,我看不到你的共享帖子,但我不得不同意ST的论坛系统与Freescales版本相比相当差!甚至没有足够的空间来查看正在尝试回复的消息!! 伊恩 以上来自于谷歌翻译 以下为原文 Hello, No sorry I can't see a shared post from you but I have to agree that ST's forums system is quite poor compared to say Freescales version! There isn't even enough room to view the message one is trying to reply to!! Ian |
|
|
|
你好,伊恩,我尝试了弱下拉,他们没有帮助。我检查了一个旧的原理图,弱拉下来是使用ST72F264时所做的。
PC5 / PA2潜在替代/外围冲突:我检查过,但我不认为这是问题所在。引脚和备选方案相应地定义: PA2 / OSC_IN / USART1_TX / SPI1_MISO PC5 / OSC32_IN / SPI1_NSS / USART1_TX 我们使用所有内部振荡器(LSI,HSI和RTC-内部32kHz) 我们不使用USART。 我们使用SPI1,但通过PB5(SCK),PB6(MOSI),PB4(启用), 一个有趣的事情是,使用SPI初始化,我们使用一个名为SPI_NSS_Soft的参数,我们还有一些命令使用SYSCFG进行模拟开关1和14的模拟路由,以及一个命令用于I / O开关将PC7连接到比较器1 。 但是,那 SYSCFG_RMPCR1 无法重新配置或PB5,PB6,PB4不能完美地为我们工作。 以上来自于谷歌翻译 以下为原文 Hello Ian, I tried weak pull downs and they didn’t help. I checked an old schematic and weak pull downs is what was done when using the ST72F264. PC5/PA2 potential alternative/peripheral conflicts: I checked, but I don’t think that’s the issue. The pins and alternates are defined accordingly: PA2/OSC_IN/USART1_TX/SPI1_MISO PC5/OSC32_IN/SPI1_NSS/USART1_TX We use all internal oscillators (LSI,HSI,and for RTC -internal 32kHz) We don’t use USART. We use SPI1, but through PB5(SCK),PB6(MOSI), PB4(Enable), The one interesting thing is that with SPI initialization, we do use a parameter called SPI_NSS_Soft, and we also have some commands using SYSCFG for analog routing at analog switch 1 and 14, and a command for I/O switch to connect PC7 to Comparator 1. However, the SYSCFG_RMPCR1 couldn’t be getting reconfigured or PB5,PB6, PB4 would not be working perfectly for us. |
|
|
|
你好,
您是否能够使用不同的已知工作GPIO引脚或GPIO寄存器的可变版本来尝试if代码? 可能与SPI1_NSS引脚PC5存在冲突,但如果您在SPI_CR2寄存器中设置SMM位,那么这不是问题吗? 伊恩 以上来自于谷歌翻译 以下为原文 Hello, Have you been able to try the if code with different known working GPIO pins or with the variable version of the GPIO registers? There might be a possible conflict with the SPI1_NSS pin PC5 but if you're setting bit SMM in the SPI_CR2 register then it's not an issue? Ian |
|
|
|
你好,
你有PA2和PC5作为输入?我首先想知道如果你在程序运行时动态更换dip开关,你是否会接触到反弹?其次是中间和确实需要&& (分别为位智能和逻辑AND运算符)。你使用括号和!很好。 测试逻辑的另一种方法是用变量替换GPIOx语句,每个开关一个,然后使用调试器将变量设置为0和1(在正确的位位置)。 希望有所帮助。 伊恩 以上来自于谷歌翻译 以下为原文 Hello, Have you got PA2 and PC5 set as an input? I'm firstly wondering if you are getting contact bounce if you are changing the dip switches on the fly while the program is running? Secondly the middle & does indeed need to be && (bit wise and logical AND operators respectively). Your use of brackets and ! is fine. Another way to test your logic is to replace the GPIOx statements with variables, one per switch and then use the debugger to set the variables to 0 and 1 (in the correct bit position). Hope that helps. Ian |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2801 浏览 1 评论
3258 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1832 浏览 1 评论
3684 浏览 6 评论
6082 浏览 21 评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
384浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
475浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
303浏览 2评论
使用STM32F407VET6的USB2.0功能,发现ctl后芯片无数据返回,是什么原因可能导致的呢?
224浏览 2评论
用STM32G431开发工程,1.50版本的Package包文件无法输出项目工程
328浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-25 09:12 , Processed in 0.975186 second(s), Total 56, Slave 51 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号