Help with understanding OutputCompare

Hi folks,

I’m currently using some sample code from the wiki to implement some IR learning / emitting functionality, and handling the IR output using OutputCompare to send a buffer of commands over a carrier frequency.

I’ve got stuff working, but I’d like to better understand some of the parameters that OutputCompare.SetBlocking uses. First one is the first parameter, initialState.

In the sample code I started from, initialState is set to true, but there’s no real explanation of why, or what this does. I noticed that after the first call to SetBlocking, with initialState set to true, the IR LED remains on. If I change initialState to false, the IR LED still appears to blink, and it goes off after the command completes, but the receiving device no longer functions, so clearly this is not doing what I want.

Can anyone give me a concise description of what the initialState parameter of SetBlocking is doing? I would welcome more detail on OutputCompare in general, but figuring out this parameter would be a nice starting point.

Thanks!

It is a digital waveform generator. It start with some known initial state and then toggles the pin every x time. The x is the array you pass to it.

@ Gus,

Right…I get that part. :slight_smile:

Perhaps I’m explaining my confusion poorly (might be why I’m confused).

What I’m trying to understand is why my code successfully drives the IR receiving device when the initialState parameter is set to [italic]true[/italic], but does not work when the parameter is set to [italic]false[/italic].

Does it matter that the IR LED stays on after calling SetBlocking with an initialState of [italic]true[/italic]?

Is that expected behavior?

The initial state will determine how all will look. The data will look mirrored otherwise.

OK, that makes sense now.

One more question…is there a way to tell the IR LED to shut off after the command has been issued? Or should I just not be worrying about it?

Thanks!

You can set the pin low but this is not important.