完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
你好,
我想编写一个程序来测试向量的值。 是有另一个更简单的解决方案?? GPIO_DeInit(GPIOB); GPIO_Init(GPIOB,GPIO_PIN_0,GPIO_MODE_IN_PU_NO_IT); GPIO_Init(GPIOB,GPIO_PIN_1,GPIO_MODE_IN_PU_NO_IT); GPIO_Init(GPIOB,GPIO_PIN_2,GPIO_MODE_IN_PU_NO_IT); if(((GPIO_ReadInputData(GPIOB)& GPIO_PIN_0)== 0))&(((GPIO_ReadInputData(GPIOB)& GPIO_PIN_1)== 0))& (((GPIO_ReadInputData(GPIOB)& GPIO_PIN_2)== 1)) { //做手术1; } 其他 if(((GPIO_ReadInputData(GPIOB)& GPIO_PIN_1)== 0))&(((GPIO_ReadInputData(GPIOB)& GPIO_PIN_1)== 0))& (((GPIO_ReadInputData(GPIOB)& GPIO_PIN_2)== 1)) { //做手术2; } ........ ........ ........ ........ 其他 操作n; 以上来自于谷歌翻译 以下为原文 Hello, I want to write a program to make his test on the value of a vector. is that there is another simpler solution?? GPIO_DeInit(GPIOB); GPIO_Init(GPIOB, GPIO_PIN_0, GPIO_MODE_IN_PU_NO_IT); GPIO_Init(GPIOB, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT); GPIO_Init(GPIOB, GPIO_PIN_2, GPIO_MODE_IN_PU_NO_IT); if (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_0)== 0)) &(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0))& (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_2)== 1)) { //do operation 1; } else if (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0)) &(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0))& (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_2)== 1)) { // do operation 2; } ........ ........ ........ ........ else operation n; |
|
相关推荐
10个回答
|
|
|
这就是那种事情 - 但是你不认为一个声明可能更适合......?
以上来自于谷歌翻译 以下为原文 That's the kind of thing - but don't you think that a statement might be more approrpriate...? |
|
|
|
|
|
|
|
|
|
|
|
谢谢您的回答。
你的意思是: if(((GPIO_ReadInputData(GPIOB)== 0x00)) { 操作1 } else if(((GPIO_ReadInputData(GPIOB)== 0x01)) { 操作2 } else if(((GPIO_ReadInputData(GPIOB)== 0x10)) 其他 { 操作 } 以上来自于谷歌翻译 以下为原文 thank you for your answer. did you mean: if (((GPIO_ReadInputData(GPIOB) ==0x00 )) { Operation 1 } else if (((GPIO_ReadInputData(GPIOB) ==0x01 )) { Operation 2 } else if (((GPIO_ReadInputData(GPIOB) ==0x10 )) else { Operation n } |
|
|
|
|
|
是的,只是我在读取数据和语法特定STM8S的水平上有一些问题。
谢谢 以上来自于谷歌翻译 以下为原文 yes, it's just I have a few problems on the levels of reading data and syntax specific STM8S. Thank you |
|
|
|
|
|
这里没有特定的STM8!
就语法而言,您只是调用一个返回整数值的函数! 以上来自于谷歌翻译 以下为原文 There is no here specific to th STM8! As far as syntax is concerned, you are just calling a function that returns an integral value! |
|
|
|
|
|
是的,你是对的,这是一个已定义的函数调用。
我用另一种方法尝试的另一个问题,但它不起作用。 如何读取初始化为inpout的端口的值。 谢谢 以上来自于谷歌翻译 以下为原文 yes you are right, it's a function call already defined. Another question I tried with the other method but it does not work. how to read the value of a port initialized as inpout. Thank you |
|
|
|
|
|
''我尝试了另一种方法''
还有什么方法? ''但它不起作用'' 说''它不起作用''永远不会有用。 你需要准确说明你做了什么,你期望发生什么,实际发生了什么,以及你采取了哪些步骤来解释差异。 ''如何读取港口的价值'' 这究竟是什么呢?! 以上来自于谷歌翻译 以下为原文 ''I tried with the other method'' What other method? ''but it does not work'' Saying, ''it does not work'' is never useful. You need to state precisely what you did, what you expected to happen, what actually happened, and what steps you have taken to explain the difference. ''how to read the value of a port'' Isn't that exactly what does?! |
|
|
|
|
|
我的意思是:我将传感器连接到端口B,它给出了5位的值。同
这个值我将选择输出。 对于(;;) { 开关(GPIO_ReadInputData(GPIOB)) { 情况0:指令0;打破; 案例1:指令1;打破; .. .. .. .. 案例31:指令n;打破 默认:指令; brek } } 没有编译和调试的问题。 但是端口B的每次值变化:我发现没有有效的输出 以上来自于谷歌翻译 以下为原文 I meant: I connected a sensor to port B which gives a value of 5 bit. with this value I will make the selection of outputs. for(;;) { switch(GPIO_ReadInputData(GPIOB) ) { case 0: instruction 0; break; case 1: instruction 1; break; .. .. .. .. case 31:instruction n; break default: instruction; brek } } no problems with the compilation and debug. but every change of value of port B: I find no valid output |
|
|
|
|
|
''没有编译和调试的问题''
你实际做了什么调试? 如果将值读入中间变量,则调试会容易得多: port_b_value = GPIO_ReadInputData(GPIOB); switch(port_b_value)''但是端口B的值每次都改变:我找不到有效的输出'' 赦免? 请注意,您不断读取端口B的值,并在其上运行switch(); 当值为......时,运行switch()不是更好吗? 以上来自于谷歌翻译 以下为原文 ''no problems with the compilation and debug'' What debugging have you actually done? It would be a lot easier to debug if you read the value into an intermediate variable: port_b_value = GPIO_ReadInputData(GPIOB); switch( port_b_value ) ''but every change of value of port B: I find no valid output'' Pardon? Note that you are constantly reading the value of port B, and running the switch() on it; Wouldn't it be better to just run the switch() when the value has ...? |
|
|
|
|
|
''我将传感器连接到端口B,它给出了5位的值''
那么什么连接到端口的其他3位? 除非你绝对肯定他们 - 并且永远都会 - 保证是零,你需要''掩盖''那些其他位...... 以上来自于谷歌翻译 以下为原文 ''I connected a sensor to port B which gives a value of 5 bit'' So what is connected to the other 3 bits of the port? Unless you are absolutely certain that they are - and always will be - guaranteed to be zeros, you need to ''mask-out'' those other bits... |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1465 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1518 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3664 浏览 1 评论
3856 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2475 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
745浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
678浏览 5评论
723浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
962浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
763浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 10:04 , Processed in 1.862025 second(s), Total 90, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1427