Hello all,
I spent a whole day with trying to get the LED-Blinky example working on my customer target Hardware without success. I read through the documentation, countless posts, tried this and that but did not find a solution which worked. Very frustrating. Hope that someone here can give me some hints.
Here is what I did:
First I downloaded and installed the LPC54004 SDK stuff in the MCUXpresso IDE. Then I set up pins, clocks and some of the peripherals. Then I took the LPC54s018 "Hello world" code example. This was recommended by NXP since that processor is pretty close to the LPC54005. I managed to compile and run/debug the "Hello world" example on my customer target Hardware and it's doing what it's supposed to do.
Then I made a copy of the project, took parts of the 54s018_led_blinky example source code and replaced some of the code of the Hello World example with it.
The debugger tells me that the systick handler is never called.
Questions:
1.) What are potential reasons that prohibit this from working ?
2.) In the clock tool, I can set the source and div ratio for the systick clock.
But the systick period is also set in the code, using
SysTick_Config(SystemCoreClock / 1000U)
Two configs ? Which one is relevant ?
Thanks for your help
Here is the rest of the code:
/*
* Copyright 2016-2023 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file LPC54005_Project.c
* @brief Application entry point.
*/
#include <pin_mux.h>
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "clock_config.h"
#include "LPC54005.h"
#include "fsl_debug_console.h"
/* TODO: insert other include files here. */
/* TODO: insert other definitions and declarations here. */
/*******************************************************************************
* Definitions
******************************************************************************/
//GPIO_0_1
#define BOARD_GPIO_PORT 0U
#define BOARD_GPIO_PIN 1U
/*******************************************************************************
* Prototypes
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/
volatile uint32_t g_systickCounter;
/*******************************************************************************
* Code
******************************************************************************/
void SysTick_Handler(void)
{
if (g_systickCounter != 0U)
{
g_systickCounter--;
}
}
void SysTick_DelayTicks(uint32_t n)
{
g_systickCounter = n;
while (g_systickCounter != 0U)
{
}
}
/*
* @brief Application entry point.
*/
int main(void)
{
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
PRINTF("\r\nGPIO TOGGLE TEST\r\n");
/* Set systick reload value to generate 1ms interrupt */
if (SysTick_Config(SystemCoreClock / 1000U))
{
while (1)
{
}
}
PRINTF("SYSTICK CONFIGURED\r\n");
while (1)
{
/* Delay 1000 ms */
SysTick_DelayTicks(1000U);
GPIO_PortToggle(GPIO, BOARD_GPIO_PORT, 1u << BOARD_GPIO_PIN);
//PRINTF("GPIO toggeled\r\n");
}
}
So far, yes.
The first one is the handler location (in the vector table), and second one is the actual handler routine.
The location "./startup/startup_lpc54005.o" refers to a file in your project, see here (example from a project of mine):
This is the handler routine taking effect.
Do you see your code there ?
This can be deceiving.
The default handler is usually either an endless loop or an empty function body, compiled a few machine instructions. It is often impossible to observe this on source code debug level.
But getting back to your last post.
Your own handler is implemented in the main file, of which you posted the contents.
Thus the linker map file should list this file as source for the SysTick_Handler routine, not the startup file. Something seems off here.
Does the build fail if you comment out the "weak" handler in startup_lpc54005.c ?
It should.
There seems something wrong with you project. It looks like the code you are editing and that the debugger displays is not the code actually executed.
I would setup the project anew.
As a test, I added a Systick handler to one of my LPCXpresso projects that did not use Systick.
As seen here, the map file lists both instances, and the non-"WEAK" implementation first.
As implied, it is the file ./source/mcan_interrupt_transfer.c that implements the handler function.
The SysTick_Config() function is visited and it seems that the register is set correctly.
But shortly after that it gets stucked in the while loop that waits for the counter to be zero.
I'm completely new to this IDE and debugging so forgive me if I ask silly questions.
And please let me know whether you can read the screenshots. Should I upload them as attachments ?
How can I verify that the Flag is really set ?
It seems that the SysTick_CTRL_CLKSOURCE_Msk is reset after the initial configuration. Is that a problem ?
Thanks for your help
Did you try to step into the SysTick_Config() function in the debugger , and see if the interrupt gets enabled (the IE flag set) ?
This function is usually implemented as "static inline" in core_cm4.h.