# What is causing this weird decaying waveform on one of my MCU pins?

See image. Camera shot of my oscilloscope.

I'm having this weird problem with my project. I'm using a dsPIC33FJ128GP802 DSC/MCU. In this application, I'm sync-separating a CVBS signal using a LM1881 and feeding it into the MCU (channel 1.) The MCU is set up to interrupt on pin change. This part works correctly, and it drives an on screen display which I have written perfectly.

But, the weird part is that on each interrupt I'm briefly pulsing the pin RB12 to debug something. This is causing the weird decaying waveform on channel 4!! I'm expecting only a brief pulse, but it takes almost 64 microseconds (the line time) to decay to zero, almost like there is a very large capacitor on the pin (but there isn't.) Also, you can see the same effect on the falling edge, as the interrupt also triggers on that. What could be causing this? It has me completely lost!

I am using this code in my ISR:

TRISBbits.TRISB12 = 0;
asm("nop");
PORTBbits.RB12 = 1;
asm("nop");
TRISBbits.TRISB12 = 1;
asm("nop");


The nops are to ensure read-modify-write problems don't occur, but it happens with or without those nops.

• Looks tri-stated to me, instead of an I/O. Dec 12 '10 at 21:41
• @tyblu - I've posted the code. Dec 12 '10 at 21:45

What is Channel 4 - is it the pin RB12

Looking at your code, you are turning pin RB12 to an output, setting it high, then setting the pin back to high impedance (an input)

What do you have loading the pin apart from the scope ?

It looks to me like the pin is just floating, at the value you left it at - high, and the scope is pulling the pin down to ground via its input impedance...

try changing the TRISBbits.TRISB12=0; to PortBBits.RB12=0; (Leaving the pin as an output but changing it to a low)

• I think this is the correct answer. It is working now. Channel 4 is RB12. Dec 12 '10 at 22:45

You should use LATx for outputs, to avoid R-M-W problems.

• I will probably do this next time but this is more suited to be a comment than an answer as it doesn't solve my primary issue. Dec 13 '10 at 23:48