LED on SC20260N only with PWM?

Hi,

I am currently testing SCM20260N on a PCB. I have four LED’s on the PCB, but I am now starting to think I cannot use any GPIO pin to drive an output high?

I have tried the LED example:

var led = GpioController.GetDefault().OpenPin(SC20260.GpioPin.PJ4);
led.SetDriveMode(GpioPinDriveMode.Output);

while (true) {
    led.Write(GpioPinValue.High);
    Thread.Sleep(100);

    led.Write(GpioPinValue.Low);
    Thread.Sleep(100);
}

But starting to wonder if only PWM pins will works since the debugger gives me an exception error:

#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### Message: 
#### GHIElectronics.TinyCLR.Devices.Gpio.Provider.GpioControllerApiWrapper::OpenPin [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.Gpio.GpioPin::.ctor [IP: 001e] ####
#### GHIElectronics.TinyCLR.Devices.Gpio.GpioController::OpenPin [IP: 0005] ####
#### SCU.Controller.Program::Main [IP: 006a] ####

Exception thrown: ‘System.InvalidOperationException’ in GHIElectronics.TinyCLR.Devices.Gpio.dll
An unhandled exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.TinyCLR.Devices.Gpio.dll

If I use a PWM pin there are no errors, but I don’t need PWM, I just want to drive it high. Are the LCD pins not general purpose (since I am not using an LCD)? It is not really clear which pins are general purpose or mandatory/fixed for a specific purpose from the colors in pinout picture.

Or, I could not find it at least… is it mandatory to use PWM pins for LED’s even when I only want to drive max. current?

Thanks.

Remco

You used this pin somewhere else?
You set PWM on same pin?

If PWM work on PJ4 then I don’t see any reason Open a gpio fail on this pin.

No, I don’t use the pin somewhere else.
No, I do not set PWM on same pin.
According to pinout of SCM20260, PWM is not assigned for PJ4.

I don’t need PWM.

If I try to drive PJ4 high, it gives me an exception error. If I use a “PWM” pin (for instance PK1), “led.Write(GpioPinValue.High);” it does NOT give an exception error.

Can I use the LCD pins as GPIO’s?

kind regards,

Remco

Yes, that is a reason. I thought you open PWM on PJ4 ok but could not open GPIO which is weird to me. Now it make sense.

That because PJ4 is used for LCD. You can’t use that pin if LCD is active.

But if you don’t call LCD then it should be OK.

Thanks, but I am not calling any LCD either.

Post a part of the schematic where PJ4 is on your PCB

Just a quick test, opening PJ4 is OK to us.

It must be reserved somewhere, somehow in your project. Could you start a simple project and open the pin?

Hi, I declared it like you did (with separate gpioController declaration) and now it works! I am migrating from TinyCLR 1.0 and I declared as the example from the tutorial, it does not work:

        //Green indicator
        var greenLED1 = GpioController.GetDefault().OpenPin(SC20260.GpioPin.PJ4);

Thanks!

Both are same. Still work on mine.

The easiest thing to do is to start a new project and blink the LED. no point for wasting time and trying the same thing over and over I think

I suppose you are right Gus, I was just surprised it did not work earlier and the change in the code seemed to help.

It is a good recommendation to start out with testing the basic functions again with a clean slate. Thanks again for the responses though.

2 Likes