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");
}
}
Hello @Beggar
1) You can check Systick register in "Peripherals+" view as below:
2) I have no board for this chip, so only can test on LPC54018. How about create a simple new project based on LPC54005, then copy application code from blinky demo to your project, then debug check registers. If still can't work, send your project to me.
3) BTW, without Systick , does your board can work well? For example, just turn on one led of your board.
BR
Alice
Hello Alice, thanks for your comments
2) How about create a simple new project based on LPC54005, then copy application code from blinky demo to your project
That's what I did. I wrote that in my first post. The HelloWorld example is working
3) BTW, without Systick, does your board can work well? For example, just turn on one led of your board.
Yes. when I comment out
SysTick_DelayTicks(1000U);
It works fine. The GPIO toggles at a rate of around 170 kHz.
However, my Peripherals+ window is empty !?
Hello @Beggar
1) However, my Peripherals+ window is empty !?
When debug, there is value in Peripherals+ window . Please take a screenshot show yours.
2) Share your project, a simple project that can reproduce your issue, please.
BR
Alice
Hello Alice,
I set up a new LPC45005 project, replaced the pin_mux.c and pin_mux.h files to match my target hardware and made sure that the "Hello World" example works. Then I added a SysTick_Handler into the source code and started the debugger. Result: SysTick_Handler does not get called.
How do I share the project with you ?
> How do I share the project with you ?
I would say, export it as archive from LPCXpresso.
Right-click you project in the workspace/projec window, and select "Export...".
Follow through, and attach the Zip archive to a post.
There is some progress on this topic:
I changed to a Segger J-Link debugger to test if it can be used as an alternative to the MCU-Link device.
With the Segger J-Link the SysTick_Handler gets called and works fine.
Obviously the setup or behaviour of the debugger device is the root causes for the problem with the SysTick-Handler.
SysTick_Handler is working now (with Segger J-Link debugger) but I need an explanation why it's not working with MCU-Link.
I also need a setup for MCU-Link that works.
And did you try setting a breakpoint in the Systick handler ?
The "g_systickCounter" variable is manipulated there.
Systick is common to all Cortex M devices, and thus basically all toolchains come with a default hander.
With LPCXpresso, this is in "startup_lpc<nnn>.c", which is part of your project (with <nnn> is probably "54005" in your case).
The default handler in this file is declared as "WEAK", i.e. supposed to be overwritten with your code.
If the function name of your own handler doesn't match, this routine would fire, too.
So, if you cannot step into your own Systick handler, try setting a breakpoint in this default routine.
I put a breakpoint into the WEAK SysTick_Handler in startup_lpc54005.c and it is also not triggered.
So what's going on here ? What am I missing ? Never needed 3 days to toggle a GPIO in a reasonable deterministic frequency !
Isn't there something like a usleep function that just works (like in other architectures) ?
Anyone from NXP who can help me ?
Do I have to change the MCU to a none-NXP part to procees with my project ?
Kind regards
> Do I have to change the MCU to a none-NXP part to procees with my project ?
Had to reboot my work PC in the meantime, because of a forced update ...
But the basic issue wouldn't change with another vendor/MCU. Not only is Systick handling basically the same (Systick is fixed part of the core provided by ARM), you would still have to get familiar with the IDE and toolchain.
I am not a huge fan of Eclipse IDEs either, by the way.
But LPCXpresso is the most supported IDE by NXP, and the provided examples usually run out of the box.
You have not described how you had set up you project.
But as Alice suggested, the best option is to use an example project from the SDK for your MCU, or (even better) for your eval board, if you are using one.
I would check the map file.
Just open the "Debug" folder in the Project explorer view. The file is named <project_name>.map.
Double-click top open it, and seach for "SysTick_Handler". The map file should list the address it is located, and the souce/object file it was compiled from.
Maybe you somewhat mixed up your project, and the sourcefile(s) you edit are not those that take effect.
You wouldn't be the first one that happens to ...
I occasionally came across workspaces with projects that had identically named files in different folder.
To make clear which one belongs to my project, I added a "#error "<some string>" directive to it.
If the build did not throw an error, I got the wrong one ...
Hello Frank,
The map file should list the address it is located, and the source/object file it was compiled from.
There are two lines which contain "SysTick_Handler":
0x00000264 SysTick_Handler
SysTick_Handler ./startup/startup_lpc54005.o
Does that look correct to you ?