ESP8266 Developer Zone The Official ESP8266 Forum 2015-07-16T17:26:11+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=761 2015-07-16T17:26:11+08:00 2015-07-16T17:26:11+08:00 https://bbs.espressif.com:443/viewtopic.php?t=761&p=2711#p2711 <![CDATA[Re: GPIO_OUTPUT_SET and expression as bit value]]>
Thanks very much for all valuable advice you gave !

Sorry that I didn't reply your topics one by one, but we have already recorded your suggestions on BBS and we will optimize our SDK and IOT_Demo in next version.

Thanks again !

Statistics: Posted by ESP_Faye — Thu Jul 16, 2015 5:26 pm


]]>
2015-07-15T22:04:22+08:00 2015-07-15T22:04:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=761&p=2698#p2698 <![CDATA[GPIO_OUTPUT_SET and expression as bit value]]>
GPIO_OUTPUT_SET(14, count > 10)

we normally think we can do this as in C, the expression "count > 10" evaluates to a numeric where 0 = false and not 0 = true which matches the bit_value. However, take great care because GPIO_OUTPUT_SET is not a function but is instead a macro and if one looks at its internals ... you will find that supplying an evaluating expression simply won't work. What you have to do is wrap the expression in parenthesis ... for example:

GPIO_OUTPUT_SET(14, (count > 10))

If you don't, your code will compile cleanly but at runtime, you will get unexpected results.

I raised this as a bug with Espressif and supplied the workaround (adding parenthesis around the parameters inside the macro). I thought I'd chance my arm at a bounty :-) ... they responded that the bit_value has to be 0 or 1 and, at this time, can not be an expression ... fair enough ... but I couldn't find that documented ... so a heads-up chums ... be careful if you supply expressions in GPIO_OUTPUT_SET.

Statistics: Posted by kolban — Wed Jul 15, 2015 10:04 pm


]]>