Hello:
First of all I must start with the classic "I'm new to this forum so excuse if this post is in the wrong section / this was already discussed etc" I am also inexperienced in electronics as well. By the way, I really did search for this subject and found nothing, so I feel free to post this.
I used an atmega168 programmed to toggle a pin on and off using a delay loop in order to obtain a 40 khz output. Something like:
ldi r20, 0xff
ldi r21, 0x00
loop:
out PORTB, r20
delay_loop
out PORTB, r21
delay_loop
rjmp loop
I tested it using different delay times with a LED and it was working ok.
I then set the delay so that the output was 40 khz (ultrasonic).
I attached a 100 nF capacitor for decoupling a cheap piezoelectric buzzer: PORTB1-----CAP----PIEZO----GND
when I connected the circuit both the atmega168 my programmer (an usbtiny which was being used for powering the AVR board) died.
While I wait for my programmer's replacement, I tried to obtain an ultrasonic signal using another piezo and a NE555 timer using a rheostat to manually increase the frequency, worked fine for a while and when I brought the NE555 to a theoretical 100 khz the chip died as well, using the same connections: NE555_OUT-----CAP----PIEZO----GND.
Is there any intrinsic limitation for such frequencies using general purpose IC's like the ones mentioned?
Could the CAP and PIEZO combination have generated high voltage spikes?
Could some internal crystal or cap have been damaged by using them this way?
I'd really appreciate any light that could be shed on this issue by any generous light bearer!
Thanks!