Hi Mike,
Based on your "HOWTO: Create the Blinking LED example project using S32K144 SDK " I am trying to toggle all the three LEDs on the S32K144EVB_100 but I am not able to do it.
Following is the code I am running on S32DS:
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
PINS_DRV_SetPinsDirection(PTD,1<<15U|1<<16U|1<<0U);
PINS_DRV_SetPins(PTD,1<<15U|1<<0U);
PINS_DRV_ClearPins(PTD,1<<16U);
PINS_DRV_SetPins(PTD,1<<16U);
PINS_DRV_ClearPins(PTD,1<<0U);
for(;;){
int c=7200000;
while(c--);
PINS_DRV_TogglePins(PTD, 1<<15U |1<<16U|1<<0U);
}
with this code the toggling is happening between blue and yellow(red+green).
Please help.
Thanks
Shashank Anand
Hi,
from EVB schematic you can see that LEDs are connected from VDD to GPIO. That means when you Clear pin - LED is ON, when you SET pin - LED is OFF.
To turn OFF all LEDs - you need to Set particular LED pin.
You can use OR and SHIFT like:
PINS_DRV_SetPins(PTD, (1<<16U) | (1<<15U) | (1<<0U) );
or write HEX value 0x18001 (1 10000000 00000001b)
PINS_DRV_SetPins(PTD, 0x18001);
To turn ON all LEDs - you can just switch SetPins to ClearPins
PINS_DRV_ClearPins(PTD, (1<<16U) | (1<<15U) | (1<<0U) );
You can also use only one LED:
Blue ON:
PINS_DRV_ClearPins(PTD, 1 << 0);
Blue OFF:
PINS_DRV_SetPins(PTD, 1 << 0);
RED ON:
PINS_DRV_ClearPins(PTD, 1 << 15);
RED OFF:
PINS_DRV_SetPins(PTD, 1 << 15);
GREEN ON:
PINS_DRV_ClearPins(PTD, 1 << 16);
GREEN OFF:
PINS_DRV_SetPins(PTD, 1 << 16);
So - in your code you can see that in Init - at the end - you turned OFF GREEN and RED and BLUE by:
PINS_DRV_SetPins(PTD,1<<15U|1<<0U);
PINS_DRV_SetPins(PTD,1<<16U);
and turned ON BLUE by:
PINS_DRV_ClearPins(PTD,1<<0U);
As you see - in for(;;)
you are toggling between Blue On/Off and (GREEN+RED) On/Off
because BLUE was ON and GREEN+RED was OFF).
Jiri