LPC55S69 Blinky Match using SCT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S69 Blinky Match using SCT

Jump to solution
1,281 Views
jalal-san
Contributor II

Hello everyone,

Before I start my question I would like to let you know that I am relatively new to embedded, therefore please be patient with me even if I ask obvious questions and it will be much appreciated if you guys could give detailed explanation. Thank you very much in advanced.

So here is the problem, I would like to create a blinky match using SCT in LPC55S69. So I started with the demo blinky match project that you could get from the Board Support Pack. However the demo does not uses SCT. After referring the SCT_Timer_Cookbook, I tried my best to create a new project by combining the SCT blinky match coding from the cookbook and the blinky match from the demo.

But since my knowledge in embedded programming and SCT is barely enough, I failed to make the LED on the LPC55S69 board to blink. However it did light up, just not blinking.

jalalsan_0-1637971469037.png

 

So based on the SCT figure above, my understanding is that when in State 1/Event 0, the led will turn ON, and in State 0/Event 1 the LED will turn OFF. So that will create the blinking effect. But I am not sure how the state/event commands the LED to turn ON or OFF.

Now I will show my code and explain,

jalalsan_1-1637971790749.png

Firstly, I copied this code from the SCT cookbook into my blinky match demo, I guess that maybe the highlighted part will turn the LED ON or OFF, since PORT1_4 uses SCT_OUT0 in the datasheet.

jalalsan_3-1637973238699.png

Then, in the main function, I included the SCT_Init() function. I modify the previous blinky match demo by deleting the systick timer which adds 100ms delay and PortToggle function which turns off the LED.

So here are my questions, 

1. Does the "SCT0->OUT[0].CLR/SET" actually turns the led on or off ? I also have some doubt that "OUT[0]" is the same as PORT1_4. 

2. Is there anything more that I need to add ? I feel like there is something missing. I know that the SCT basically have Event 0 and 1. but how do I let it know that if Event 1 happens then this happens ? Feels like I set an event but does not set what happens to it.

I really hope my explanation helps to understand my situation. I tried to look online for tutorial but most tutorial are meant for people who are already familiar with embedded programming. If you guys have any tutorial or books to recommend, please inform me. I really need to get better in embedded programming but do not know where to start.

Thank you, I also included some files so that you can take a look at the code.

 

Labels (1)
0 Kudos
1 Solution
1,250 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jalal,

I think the code sct_init() is okay.

For your issue that you can not see the LED toggles, as you know that LED toggles at 10Hz, it is too fast to see the LED toggle.

Pls try to use the code:

LPC_SCT->MATCHREL[0].U = (SystemCoreClock/2)-1; // match 0 @ 2 Hz = 100 msec

I suggest you connect the P1_4 pin to a scope so that you can see the waveform.

If you still can not see the LED toggle, I suppose the pin configuration has error.

Pls modify the function as the following in pin_mux.c

#define IOCON_PIO_FUNC4 0x04u /*!<@brief Selects pin function 0 */
void BOARD_InitPins(void)
{
/* Enables the clock for the I/O controller.: Enable Clock. */
CLOCK_EnableClock(kCLOCK_Iocon);

/* Enables the clock for the GPIO1 module */
CLOCK_EnableClock(kCLOCK_Gpio1);

gpio_pin_config_t LED_BULE_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
/* Initialize GPIO functionality on pin PIO1_4 (pin 1) */
GPIO_PinInit(BOARD_LED_BULE_GPIO, BOARD_LED_BULE_PORT, BOARD_LED_BULE_PIN, &LED_BULE_config);

const uint32_t port0_pin10_config = (/* Pin is configured as SWO */
IOCON_PIO_FUNC6 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI |
/* Analog switch is disabled */
IOCON_PIO_ASW_DIS_DI);
/* PORT0 PIN10 (coords: 21) is configured as SWO */
IOCON_PinMuxSet(IOCON, 0U, 10U, port0_pin10_config);

const uint32_t LED_BULE = (/* Pin is configured as PIO1_4 */
IOCON_PIO_FUNC4 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN4 (coords: 1) is configured as PIO1_4 */
IOCON_PinMuxSet(IOCON, BOARD_LED_BULE_PORT, BOARD_LED_BULE_PIN, LED_BULE);
}

Hope it can help you

BR

XiangJun Rong

View solution in original post

2 Replies
1,251 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jalal,

I think the code sct_init() is okay.

For your issue that you can not see the LED toggles, as you know that LED toggles at 10Hz, it is too fast to see the LED toggle.

Pls try to use the code:

LPC_SCT->MATCHREL[0].U = (SystemCoreClock/2)-1; // match 0 @ 2 Hz = 100 msec

I suggest you connect the P1_4 pin to a scope so that you can see the waveform.

If you still can not see the LED toggle, I suppose the pin configuration has error.

Pls modify the function as the following in pin_mux.c

#define IOCON_PIO_FUNC4 0x04u /*!<@brief Selects pin function 0 */
void BOARD_InitPins(void)
{
/* Enables the clock for the I/O controller.: Enable Clock. */
CLOCK_EnableClock(kCLOCK_Iocon);

/* Enables the clock for the GPIO1 module */
CLOCK_EnableClock(kCLOCK_Gpio1);

gpio_pin_config_t LED_BULE_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
/* Initialize GPIO functionality on pin PIO1_4 (pin 1) */
GPIO_PinInit(BOARD_LED_BULE_GPIO, BOARD_LED_BULE_PORT, BOARD_LED_BULE_PIN, &LED_BULE_config);

const uint32_t port0_pin10_config = (/* Pin is configured as SWO */
IOCON_PIO_FUNC6 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI |
/* Analog switch is disabled */
IOCON_PIO_ASW_DIS_DI);
/* PORT0 PIN10 (coords: 21) is configured as SWO */
IOCON_PinMuxSet(IOCON, 0U, 10U, port0_pin10_config);

const uint32_t LED_BULE = (/* Pin is configured as PIO1_4 */
IOCON_PIO_FUNC4 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN4 (coords: 1) is configured as PIO1_4 */
IOCON_PinMuxSet(IOCON, BOARD_LED_BULE_PORT, BOARD_LED_BULE_PIN, LED_BULE);
}

Hope it can help you

BR

XiangJun Rong

1,248 Views
jalal-san
Contributor II

OMG! Thank you so much !

That really fixed the problem. 

>>If you still can not see the LED toggle, I suppose the pin configuration has error.

You are right, turns out the pin configuration has error. 

Your code helped me fixed it.

Thanks again for your help !

0 Kudos