Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Excessive IO ripple on microcontroller output pins

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various
View previous topic :: View next topic  
Author Message
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 216
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Sun Jul 20, 2025 2:34 am    Post subject: Excessive IO ripple on microcontroller output pins Reply with quote

Hi
I am currently testing a new designed PCB running a ATMega234pb. I have found that multiple IO pins seem to have a high ripple voltage when switched on and even when switched off.
When pin are high the ripple is 70mv and low 20mv. Has a frequency of around 4mhz.

Design notes are as follows

1. 5v Rail plane 8mv pk-pk
2. Has 100n and 2.2uf caps on Vcc for decoupling
3. Micro running a external 8mhz crystal
4. Pin currently testing PB.4 , PA.3 PD.4, PD.5


Queries
These pins are part on the Peripheral Touch Controller (PTC), but I'm just using them as a enable pin for a Op-amp and switch a transistor for an LCD backlight.
I don't have any success with setting the PTC off with PRR2.3 = 1 to stop the ripple.

The only way to stop the ripple is to put the micro into power save mode ( CONFIG POWERMODE = ADCNOISE) or by adding a 100nf cap to that io line

Attached are the scope readings

Code:
$regfile = "m324pbdef.dat"
$crystal = 8000000                                            'Using crystal 8MHZ frequency
$hwstack = 35
$framesize = 30
$swstack = 55

$PROG &HFF,&HFF,&HD9,&HFF' generated. Take care that the chip supports all fuse bytes.

Config pORTA.3 = Output                                  'Led on key switch
PortA.3 = 0

Do
  Cls
  pORTA.3=1

  Wait 5

  pORTA.3=0
  Wait 5

Loop


Thoughts?
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1142

poland.gif
PostPosted: Mon Jul 21, 2025 9:23 am    Post subject: Reply with quote

Check if this is not a "signal ringing" or "circuit ringing". There is some tutorials on YT. Someday I saw a very good one but now I culd not find it to link here.
_________________
Check B-Flash -my MCS bootloader app for Android (updated)
Back to top
View user's profile Visit poster's website
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 216
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Mon Jul 21, 2025 10:25 am    Post subject: Reply with quote

Hi Team,
Thanks for the input so far.

Would you consider 70 mV peak-to-peak ripple excessive? My scope only samples at 1 GHz, so the actual ripple could be higher.

Today I removed the external 8 MHz crystal and switched to the internal oscillator — unfortunately, that made no difference.

The issue first showed up after enabling an op-amp, which feeds into a 12-bit ADC. The ADC output showed ringing, which led me to start probing around and uncover this ripple.

I’m not 100% sure if the port is correctly set as an output. It’s declared as one in code, but I’m unsure whether the Peripheral Touch Controller (PTC) is still active and clocking the pins.

According to the datasheet:

Page 39, Section 10.1.3

Page 62, Section 12.11.5

These mention PRR2 bit 3 (PTC disable). I’ve tried clearing this bit (i.e., setting PRR2.3 = 0), but how can I actually verify that the PTC module is completely shut down?

Also, I’d expect the pin ripple to match or slightly exceed the Vcc ripple, which is ~8 mV peak-to-peak. For reference, I have 100 nF and 2.2 µF decoupling caps on the Vcc and AVcc pins. Interestingly, placing a 100 nF cap directly on the affected pin reduces the ripple to 20–30 mV — but from what I’ve read, that’s not really a recommended solution.

Cheers,
Snow
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 630
Location: Cleveland, OH

usa.gif
PostPosted: Mon Jul 21, 2025 3:45 pm    Post subject: Reply with quote

What are you using for your Ground Lead / Connection for your O'scope probe?

When you want to measure small signals on the PCB, you should be using the little 1/2 cm wire on the tip of the probe, and not the 6 inch long wire with an alligator clip on it.

If you are using the (usual?) 6 inch wire, move it around, use different ground points and have different orientations of the wire "Loop", and you might well see the amplitude of the signal change significantly, (meaning that the signal is largely an artifact, and not real).

JC

Back to top
View user's profile Visit poster's website
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 216
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Mon Jul 21, 2025 9:33 pm    Post subject: Reply with quote

HI JC.
Yes i a using a probe earth spring at the Gnd connection. With more luck than design I was able to test the VCC pin and the IO pins with the same GND connection point..
Also i made a typo on the previous message. Setting the PRR2.3=1 disables the PTC module. I have tried setting and clearing the register to compare the difference
but this does not make any difference.

This is my first time using this chipset ATMega324pb . I usually go with the ATMega328pb... Could this just be what the chip set does???

Cheers
Snow
Back to top
View user's profile
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 216
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Wed Jul 23, 2025 5:37 am    Post subject: Reply with quote

Hi Team,

I'm trying to read and write to the PRR2 register (address 0x66), but running into some issues.

For example:

PRR2.3 = 1 ' This line compiles, but doesn't seem to do anything
Setreg R66, 8 ' This doesn't compile
Temp = PRR2.3 ' This also doesn't compile
Also, I'm curious how BASCOM performs a fuse and lock bit read under the hood. Specifically:

For reading something like the Fuse Low Byte (at address 0x63), which holds clock setup bits, I tried:


Var = GetReg(R63) ' Doesn't compile
Var = GetReg(63) ' Also fails
Am I missing something about how GETREG or low-level register access is meant to work?

Lastly, someone suggested probing the pin that's showing a clock signal — and it does appear to be coupled. I've attached the scope results showing the behavior if that helps clarify the issue.

Thanks in advance for any insights![/code]
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6209
Location: Holland

blank.gif
PostPosted: Thu Jul 24, 2025 7:12 pm    Post subject: Reply with quote

getreg/setreg only work on registers r0-r31
but you can also use the registers direct since they are exposed to bascom :
somevar=r0 ' assign a variable with register R0

fuses reading and writing is explained in the memory programming topic in the datasheet. but this only works with external programming.
some processors allow to read signatures or fuses.
have a look at mcs.lib _readsig and the readsig() function.

PRRx registers are IO registers that work like any other IO register. but you need to check the datasheet to see if they are read only and what you need to write.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum