LPC8N04 not working @ 8MHz

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

LPC8N04 not working @ 8MHz

Jump to solution
3,733 Views
kenchill
Contributor III

Hi All

Why doesn't the LPC8N04 work @ 8MHz?

We thought it was our project, but using the LPC8N04 dev-board OM40002 and using the NFC example has the same problem.

The default NFC example 500kHz clock works fine, 4MHz works fine - but 8MHz doesn't, 'BOARD_BootClockSFRO500kHz()' is changed to 'BOARD_BootClockSFRO8MHz()'.

8MHz does work ok when debugging, stopping debug and pressing the reset button and it still works ok, a NFC tap returns the 'hello world' message - but cycle the power and the NFC message no longer works.

Am I missing some other config that has to be done when running @ 8MHz?

Can anyone hep?

Thanks

Ken Roberts

nfc‌#lpc8n04

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
3,537 Views
kenchill
Contributor III

Hi All

Clearing the LPM bit in the FLASH->FCTR before switching to 8MHz with 'BOARD_BootClockSFRO8MHz()' solves the issue, the processor now runs @ 8MHz with zero wait-states, this took a while to spot as when debugging the LPM bit is clear, I guess by using SWD it gets cleared automatically, although there is no documentation for this.

Ken...

View solution in original post

0 Kudos
Reply
11 Replies
3,537 Views
Jonathan_Iglesias
NXP TechSupport
NXP TechSupport

Hi Ken Roberts,

Hope you are doing great, 

When run in 8MHz, the WST bit should be set to 0x01 of the FBWST register ( flash wait state register) and FLASH ->FBWST register needs to be set before clock configuration, 

void BOARD_InitBootClocks(void)
{

FLASH->FBWST=(FLASH->FBWST &~0x00FFu)|(uint32_t)(0x01&0xFF);

BOARD_BootClockSFRO8MHz();

}‍‍‍‍‍‍‍‍‍

in addition, some hardware reworks are recommended :

pastedImage_2.png

For example, add two 100nF capacitors on PIO_3 and PIO_7 and set  to logic 1.

BR

Jonathan

0 Kudos
Reply
3,537 Views
kenchill
Contributor III

Thanks for your reply Jonathan,

We have used the LPC8N04 in a few projects as it is such a useful device - but the docs and API are frustrating, so much is missing and hidden.

Adding a wait-state to the FLASH will mean it will be running @ 4MHz won't it? - but I think I have found the issue (I'll know for sure shortly), the reset value of the LPM bit in the FLASH->FCTR is high = low-power mode and 8MHz FLASH operation needs one wait-state in LPM (table 149), so the LPM bit should be cleared  for zero wait-state 8MHz FLASH operation, this should happen in 'BOARD_BootClockSFRO8MHz()'.

Adding the capacitors to the i/o pins is recommended for energy-harvesting mode - but as we have a couple of spare i/o's we will add capacitors to them.

Thanks for your comments

Ken...

0 Kudos
Reply
3,538 Views
kenchill
Contributor III

Hi All

Clearing the LPM bit in the FLASH->FCTR before switching to 8MHz with 'BOARD_BootClockSFRO8MHz()' solves the issue, the processor now runs @ 8MHz with zero wait-states, this took a while to spot as when debugging the LPM bit is clear, I guess by using SWD it gets cleared automatically, although there is no documentation for this.

Ken...

0 Kudos
Reply
3,537 Views
kenchill
Contributor III

Thanks for your reply Ivan,

But the power is being cycled by unplugging the USB cable and plugging it back in.

Please try the simple NFC driver demo with the OM40002 LPC8N04 dev-board - and you will see the issue yourself.

Thanks

Ken...

0 Kudos
Reply
3,537 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

Which is the demo you are trying to run? is it a SW example from the MCUXPresso SDK?

BR,

Ivan.

0 Kudos
Reply
3,537 Views
kenchill
Contributor III

Hello Ivan

I am using MCUXpresso IDE.

The example I am using is:

File->New->Project->Import SDK Examples->lpc8n04devboard->driver_examples->nfc->nfc_example.

Ken...

0 Kudos
Reply
3,537 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

I am not able to download the examples due to broken link which I already reported. But could you please make sure that SYSCLKDIV is set to 000b (No division). And also compile the project in release mode to work without the debug mode.

Thank you,

Ivan.

0 Kudos
Reply
3,537 Views
kenchill
Contributor III

Hi Ivan

The SYSCLKDIV is set to 0, here is the NXP api code:

/*******************************************************************************
* Code for BOARD_BootClockSFRO8MHz configuration
******************************************************************************/
void BOARD_BootClockSFRO8MHz(void)
{
/*!< Set up the clock sources */
CLOCK_SetSysClkDiv(kCLOCK_SysClkFreq8MHZ); /*!< Set SYSCLKDIV */
CLOCK_SetClkDivider(kCLOCK_DivSspClk, 0U); /*!< Set SSPCLKDIV */
CLOCK_Select(kWDT_Clk_From_Sfro); /*!< set WDT from SFRO */
CLOCK_SetClkDivider(kCLOCK_DivWdtClk, 0U); /*!< Set WDTCLKDIV */
CLOCKOUT_Enable(0); /*!< disable CLOCKOUT */
/*!< Set SystemCoreClock variable. */
SystemCoreClock = BOARD_BOOTCLOCKSFRO8MHZ_CORE_CLOCK;
}

I compiled in release mode and the problem still remains.

This is the main() function:

int main(void) {

   /* Init hardware*/
   BOARD_InitPins();
// BOARD_BootClockSFRO500kHz();
// BOARD_BootClockSFRO4MHz();
   BOARD_BootClockSFRO8MHz();

   NFC_Init(DEMO_NFC);
   NFC_WritePage(DEMO_NFC, 0, (const uint32_t *)s_nfcData, sizeof(s_nfcData) / sizeof(uint32_t));

   while(1) { }
}

Ken...

0 Kudos
Reply
3,535 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

Only to confirm, the function of this SW example is really simple, to send a formatted NDEF text message ("Hello world") to the Smartphone. How is this behavior that you mentioned, is it that it is restarting on Phone's side when riding the message, and it cycles reading it? or the LPC8N04 does not send the message to the phone at all? Do you notice this behavior for other clock speeds?

Does you final requirement need the board to be powered? Otherwise, please remember that if the final application is only though energy harvesting, the clock will be 2 MHz.

Thank you,

Ivan.

0 Kudos
Reply
3,535 Views
kenchill
Contributor III

Hi Ivan

Our project is a lot more complicated than this example but we have come across this problem with previous projects - although they were ok @ 4MHz, the current project must run @ 8MHz.

This simple SW example was chosen as it highlights the issue, it works fine @ 4MHz and below but not 8MHz.

The problem is it cannot be debugged as it works ok @ 8MHz when the debugger is running, stopping the debugger and pressing the reset button on the dev-board and the 'hello world!' message is still returned when tapped with a phone. But remove the USB lead and plug it back in and there is no NFC message on phone tap.

On our real project the clock speed is switched from 500kHz to 8MHz only when it is confirmed that the battery is present, the speed is limited to 500kHz if energy harvesting.

Ken...

0 Kudos
Reply
3,535 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

If you are working without a battery/vdd connection to a power source (such as your computer for debugging) on your board, but only with energy harvesting, the system clock is limited to 2 MHz. Please refer to chapter 8.3.1 of datasheet, in case you need to understand the parts that might be affecting the 8 MHz or need to be set up in case the board is powered by a source different than energy harvesting.

Hope it helps!

BR,

Ivan.

0 Kudos
Reply