Electronics > Projects, Designs, and Technical Stuff
STM32 blinking 30 LED's!
<< < (3/6) > >>
Renate:

--- Quote from: OM222O on September 02, 2019, 07:33:11 pm ---If you need individual LED control with as few pins as possible, you should use charlieplexing.
--- End quote ---
But since we've got enough pins, some degree of multiplexing would be sensible without getting into the duty cycle or constant current driving problems of charlieplexing.


--- Quote from: OM222O on September 02, 2019, 07:33:11 pm ---
--- Code: ---if ((millis() -lastMillis) > 5000)
--- End code ---

--- End quote ---
Are we there yet?
Are we there yet?
Are we there yet?


--- Quote from: OM222O on September 02, 2019, 07:39:58 pm ---You can play around with tricks such as setting them to input to simulate a High-Z state, but it's not a real tri-state pin.
--- End quote ---
The DDR registers are simply tri-state enables. They only affect the output enable. All port pins are always actively inputs.
From Atmega328P datasheet.

--- Quote ---Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit.
--- End quote ---


--- Quote from: Yansi on September 02, 2019, 08:06:57 pm ---I think I shall not visit any arduino threads, or I'll get a stroke.
--- End quote ---
I think that I'm with you on this one.
OM222O:

--- Quote from: Yansi on September 02, 2019, 08:06:57 pm ---Changing to HiZ takes a few clocks you say?   And changing output to 1 or 0 doesn't taky any or what?

I think I shall not visit any arduino threads, or I'll get a stroke.

--- End quote ---

It takes only 1 cycle via direct register manipulation, you can test it with an oscilloscope. just write pin change statements one after another and see how the frequency is 16MHz for something like arduino nano, uno, etc (which is the system clock). (make sure to write them back to back, and not just two inside a loop, the loop itself takes something like 8 or 10 cycles as far as I can remember). then repeat the same experiment: write the pin to output high, set it to input, back to output high and repeat a few times. even with direct register control, it takes more than 1 cycle to do it (I'm not sure exactly how many since I did this a long time ago! might be worth repeating to take some pictures this time).


--- Quote from: Renate on September 02, 2019, 09:33:50 pm ---Are we there yet?
Are we there yet?
Are we there yet?

--- End quote ---

Going into actual interrupt timers would be opening a whole new can of worms, but it would be a better and more accurate method, I agree! this was just a quick and dirty workaround  :P


--- Quote from: langwadt on September 02, 2019, 08:26:04 pm ---what 's not "real tri-state" about setting a pin to input?

--- End quote ---

I really don't want to get into nitty-gritty details, but that creates a quasi tri state logic device. You can refer to arduino forums / Wikipedia for low level details  :-+

Edit: regarding speed testing of arduino, julian ilett has done a video on it that you can watch here if you don't wanna go through the trouble of actually doing it yourself  :popcorn::
langwadt:

--- Quote from: OM222O on September 02, 2019, 09:39:06 pm ---

--- Quote from: langwadt on September 02, 2019, 08:26:04 pm ---what 's not "real tri-state" about setting a pin to input?

--- End quote ---
I really don't want to get into nitty-gritty details, but that creates a quasi tri state logic device. You can refer to arduino forums / Wikipedia for low level details  :-+

--- End quote ---

so it is tri-state but "quasi tri state logic device" sounds more fancy?
OM222O:

--- Quote from: langwadt on September 02, 2019, 10:23:09 pm ---so it is tri-state but "quasi tri state logic device" sounds more fancy?

--- End quote ---

not quite!
To put it in very basic terms: High Z mode is basically like an open circuit (think of it as a switch that disconnects the pin from the circuit). In most micro controllers they don't implement a Tri-State buffer, rather an "Output Enable" for the output driver and leave the pin connected to the input like others mentioned:


--- Quote from: Renate on September 02, 2019, 09:33:50 pm ---The DDR registers are simply tri-state enables. They only affect the output enable. All port pins are always actively inputs.
From Atmega328P datasheet.

--- Quote ---Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit.
--- End quote ---

--- End quote ---

That means by de-activating the output enable, you're not driving the pin anymore, but it's also not in the high impedance mode (it's not actually disconnected), hence the name: "quasi tri-state"

You can read more here: https://en.wikipedia.org/wiki/Three-state_logic
There's just a subtle difference in terminology and low level technical details, but you can think of the two as functionally equal.

I have to apologize to the OP since this topic has gone off on a huge tangent, please focus on the main question that the OP asked. Thanks  ;D
Renate:

--- Quote from: OM222O on September 02, 2019, 09:39:06 pm ---Julian Ilett has done a video on it...
--- End quote ---
That video should really be entitled, "How slow can you make an ATmel processor if you are silly enough to use digitalWrite()?"
And no, I didn't watch all 15 minutes.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod