Configuring Open Drain IO output type. #204
Replies: 11 comments
-
Posted at 2014-02-10 by @gfwilliams Well, you should be able to use pinMode: http://www.espruino.com/Reference#l__global_pinMode However this doesn't include support for open drain outputs at the moment (although it can do internal pullups). I've created an issue for it here: espruino/Espruino#225 If you want it right now, you might find it interesting to use I haven't tried this, but something like it should work:
A0 is easy because it's the bottom 4 bits of port A :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-10 by dprime Excellent, thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-10 by dprime It almost works...
Gives this output:
I think the analogWrite clearing the output type might be down to jshPinSetFunction() where it does:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-10 by dprime In the previous post on Line 4 of the first code example, I originally set the output to 0b0100 not 0b1100. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-10 by dprime Having a bad 5 minutes... Please ignore previous post. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-11 by @gfwilliams So it works, but every time you say You could try |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-11 by dprime Yes it works but analogWrite() function is overwriting the output type (CNF0 which defines push-pull or open-drain) back to push-pull each time. Using pinMode() to set pin A0 to output mode first, the code below shows this behaviour:
Output, comments added manually:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by @gfwilliams Thanks. Ok, so if you want to keep changing the PWM value you'll have to wait until I get around to adding If you really can't wait, you can poke into the relevant timer's duty cycle register :) Either that or if high frequency is not vital you can use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by dprime Thanks Gordon. I can work around the problem for now by poking the output config back to open-drain each time I change the PWM as I'm not doing it often at the moment and the short push-pull spike can be filtered out. I'm really impressed with how easy the board and SW is to use. Great for prototyping and testing various hardware ideas out. David |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by @gfwilliams Just to say that I've just fixed this: espruino/Espruino#234 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-15 by dprime ok, thanks. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-09 by dprime
Is there any way to set an IO pin output type to open drain, rather than push-pull?
I want to connect some PWM outputs to ZXLD1366 Power LED drivers. The ADJ input of these devices can be driven directly by an open collector/open drain PWM source to adjust the LED brightness.
I guess this question also extends to IO inputs, and setting the optional internal pull-up or pull-down resistors.
Beta Was this translation helpful? Give feedback.
All reactions