Atmega328p PWM outputs ans ICSP

Hello guys,
i plan to use an atmega328q (tqfp32) to control some leds drivers IC.

Atmega will be mounted on a specific PCB. And will be not loaded with arduino bootloader.
As the analogWrite() page explain

The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g. 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.

Is this possible to share the ICSP pins (atmega pin 13/14/15) to drive leds when device is on operational mode and use icsp on the early time to flash bootloader ?
See bellow picture for what i intend to do. Can someone gives me an advice about this

Thanks for your help.
GuiTwo

Given that you have the proper resistors - 220 Ohm or more - in series with your LEDs, the only requirement would seem to be that your ICSP programmer also uses an ATmega chip with the ability to drive those LEDs in the process of programming.

Whatever does this have to do with analogWrite?

Doesn't your ICSP header have RESET, and power? Also you didn't show where the SPI lines go when they leave the portion of the diagram you cut out and pasted. It's important to know what they're connected to.

I did indeed wonder about that. :thinking:

Cross post reported.

Hello,
Can someone confirm that there's nothing missing on this scheme to flash arduino bootloader (with either tinyISP or another arduino board). This device will be soldered on a PCB and I will not be able to change connection afterthat, that's why i'm a little concerned.
Note that i do not use external crystal and i plan to use the device with internal oscillator. VCC is a regulated voltage.

Thanks for your help and time.
GuiTwo

I have merged your two topics about this subject @gchardin.

In the future, please create only one forum topic for each distinct subject matter.

Thanks in advance for your cooperation.

Hello,
ctrl_LEDx are connected to the dimming pin of a IC led driver, not LED/resistors.

Whatever does this have to do with analogWrite?

I'll use PWM feature of arduino to drive led current.

Doesn't your ICSP header have RESET, and power? Also you didn't show where the SPI lines go when they leave the portion of the diagram you cut out and pasted. It's important to know what they're connected to.

Not for now, i was thinking that is not mandatory (project is battery powered, and will be on while flashing and reset could be performed manually by powering off). If it is i'll add those right away.

Don't you mean, "guessing"?

Right, guessing.

So you don't think there is a need to connect the ground of one device to the ground of another when you connect the two? :thinking:

I'm pretty sure the USBASP or equivalent has to hold the part in a reset state at some times during the upload process. So just power cycling your board probably won't work.

Anyway, can't you just look at every similar design and see that it has it? It's not food for thought?

Ok, i add those connections.

Thanks to @Paul_B pointing this... Obvious info !

So you don't think there is a need to connect the ground of one device to the ground of another when you connect the two?

@anon57585045 , i looked to uno design file, but i decided to get rid of thoses connections.

On what grounds? Couldn't resist.

@anon57585045 Corrected !
image

Why do you have a resistor from RESET to ground? Edit - that can't ever do anything because RESET is hard wired to Vcc?

It looks like you want to build this by having forum members correct 1000 bad guesses...

Doesn't work that way with a LED.
PWM only controls the 'on' time of the LED, not the current.
LED current will be what you set with hardware, unless you unspecified driver is different.

ADC6 and ADC7 are analogue input only.
Can't be used to drive LEDs.
Leo..

I add this pullup resistor originally to not have reset pin floated and permanently connected to vcc. Was before your remark about ICSP reset pin connected to reset. I did not check this while posting back the screenshot.

:+1: :roll_eyes:

Well spotted! :+1:

I read the "serial downloading" chapter from atmel datasheet. Now i understand why reset pin on icsp is mandatory.
It answers another question about external component needed (specifically crystals) :

If the device is clocked by the internal oscillator, it is no need to connect a clock source to the XTAL1 pin.

So crystals are not mandatory (if fuses are correctly set).

And no, do not try to guess everything, but try to do my best and go find help sometime.
So thank you.