| Author |
Message |
frederic Newbie
 Joined: 30/03/2018 Location: FrancePosts: 15 |
| Posted: 06:20pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
Hello all, i tried CIN on my MMX144 project, i use version : 5.04.18 SETPIN 6,CIN, PULLDOWN >>>Error: Unexpected text
PULLDOWN is my problem !!!
design on my project have no external pulldown and i need one internal pulldown could be a miracle!!!
thanks in advance
fred |
| |
CaptainBoing
 Guru
 Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
| Posted: 06:44pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
The manual shows the syntax
SETPIN pin, cfg [, option]
but the options PULLUP & PULLDOWN are only associated with DIN.
Don't know if it is possible to have them with CIN/PIN/FIN - may conflict internally with the pin circuitry... don't know. Probably a "nice to have".Edited by CaptainBoing 2019-01-17 |
| |
twofingers
 Guru
 Joined: 02/06/2014 Location: GermanyPosts: 1671 |
| Posted: 06:56pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
Hmm, I guess that'a a bug. (MMBasic v5.1 / MX170-28)
The same behavior on a MX170.
SETPIN 16, DIN, PULLDOWN No error message.
SETPIN 16, CIN, PULLDOWN Error: Unexpected text
EDIT It seems that CB is correct!
Edited by twofingers 2019-01-17 causality ≠ correlation ≠ coincidence |
| |
CaptainBoing
 Guru
 Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
| Posted: 06:58pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
It isn't if you take the manual literally.
" DIN Digital input If 'option' is omitted the input will be high impedance If 'option' is the keyword "PULLUP" a simulated resistor will be used to pull up the input pin to 3.3V If the keyword "PULLDOWN" is used the pin will be pulled down to zero volts. The pull up or down is a constant current source or sink of about 50μA. "
these options are not mentioned for any other configEdited by CaptainBoing 2019-01-17 |
| |
CaptainBoing
 Guru
 Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
| Posted: 07:02pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
I wonder if you could set it to PULLDOWN then use the ChangePin CSUB to modify the config. That CSub is a quick & dirty tweak and may only address the thing you specify - i.e. not "policing" the pin. It needs to be used with care as you can confuse MMBasic with it.
" ChangePin This is an embedded C module which will force an I/O pin into some state. Note that: MMBasic does not know about this change and will still think that the pin is in its original setting. There is no error checking on the arguments supplied to this subroutine and invalid values will probably cause an exception and a processor reset. It is possible to place an I/O pin into a nonsensical configuration and in that case the outcome is undefined. "
sounds just the ticket! I would try enabling the pulldown resistor after you have set it as CIN
ChangePin pin, 18 'CNPDSET
the example in the doc tends to suggest this is entirely do-able: " Using the Function As an example the following will add an internal pullup resistor to a frequency input pin: SETPIN 15, FIN ' set pin 15 as a frequency input CHANGEPIN 15, 14 ' add a pullup resistor to that pin "
p.s. the CSub is in "ChangePin.pdf" in the Embedded C Modules folder of the distribution.
EDIT: ARGH!!! MMX!!! No CSubs! Edited by CaptainBoing 2019-01-17 |
| |
matherp Guru
 Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
| Posted: 07:19pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
You can't have pullups or downs on an output. You can set the pin to open collector and use an external pullup:
SETPIN n,DOUT,OC |
| |
matherp Guru
 Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
| Posted: 07:21pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
The MM syntax doesn't allow for pullups and pulldowns on a counting/frequency input. Ignore previous post -duh Edited by matherp 2019-01-17 |
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9754 |
| Posted: 09:49pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
Just my 2c: Be careful when using ANY of the internal pull-up's or pull-downs. Some sensitive peripheral devices do not like the taste of the fake resistor used internally as the pull-up or pull-down. This 'resistor' is formed out of a semiconductor junction, and is not an actual resistor. The PULLUP and PULLDOWN commands are probably fine for simple push-button inputs, but anything else and I strongly recommend you always use external resistive pullups or pulldowns.
I have had issues specifically with the internal pull-up applied to the COM ports when talking to SOME devices. The one that gave me the most trouble, was the SIM7600SA SMS module. NOTHING I did would allow it to talk back to the MM with the automatic pull-up in place. On that thread, I was really scratching my head, as the logic-analyser COULD see the response from the module, but the MM totally ignored them. As soon as you connected the logic analyser to the MM COM port pin, the data vanished.
A clever member whose name escapes me right now, suggested I try the ChangePin function, to disable the internal pull-up on the COM RX pin, and hey-presto! The module has been working flawlessly since then. However, the internal pullup is enabled by default when you open the COM port, so unless you manually disable it after having opened the port, you might get COM port problems on SOME devices.
As I say - the internal pull-up seems fine for button or switch inputs to save you a pull-up resistor, but for COM ports, I now tend to disable the internal pull-up, and suplly my own external one in the area of 4k7 to 10k. 10k is my normal go-to value for pull-ups or pull-downs on any I/O pin. ....along with a series 1k to the pin, for a bit of current protection. Smoke makes things work. When the smoke gets out, it stops! |
| |
CaptainBoing
 Guru
 Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
| Posted: 11:12pm 15 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
+1 I had a canter with them a couple of years back, there's a thread on TBS about it somewhere |
| |
frederic Newbie
 Joined: 30/03/2018 Location: FrancePosts: 15 |
| Posted: 10:43am 16 Jan 2019 |
Copy link to clipboard |
 Print this post |
|
thanks all !! no pullup/pulldown on CIN or FIN i will modify my pcb and add external pulldown i use an optocoupler, that the reason i need pulldown
thanks all !!
fred |
| |