Make blinky example work for the cortex M4 and the cortex M0

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

Make blinky example work for the cortex M4 and the cortex M0

2,197 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by floreste on Fri Jun 27 06:21:11 MST 2014
Hello,
I have some troubles programing a MCU and would appreciate some enlighten.
I am trying to program the LPC 4337 (The Xplorer board) with the LPC Link-2 debug probe in order to run a simple blinky program on cortex M4 and M0 in sleep, and then to run the same program with the cortex M0 and M4 in sleep. As IDE for programming I am using the NXPXpresso IDE.
I have already managed to run my program in the M4 but I’m experiencing troubles for the M0 part: I can’t make any project work.
Here is what I have understood and tried, please tell me what I did wrong or what I have missed.
I first tried to run the examples from the LPCopen package. Since I have a LPC4337 board, I have changed the settings for the examples and put LPC4337 for the M4 examples and LPC4337-M0 for the M0 examples.
I wanted to try the blinky projects, and here is the first thing I have noticed:
Periph_blinky and freertos_blinky examples seems to work, (connected with JTAG for cortex M4 and without any link to M0APP in the settings (Settings->tool Settings->MCU Linker->Multicore) ) when they are programmed independently from the M0.
But first problem, with the same settings as the other working examples, the dc_sa_blinky example ends in the HardFault_Handler, according to what I’ve seen, after checking if the M0 image was correctly loaded, which could not since I hadn’t already linked the M4 project to the M0 one.
Then, I tried to make the _m0 examples work by themselves changing the settings to LPC4337-M0 and using the JTAG dedicated for the M0 but then, I am each time “stalled on bus operation” (this message is displayed on the bottom of the NXPXpresso IDE).  I guess that I can’t run a program only dedicated for the M0 since the M4 has to boot the M0 core?
So I tried to link the 2 projects to run a multi core program, and here is where I would like some help to guide me in the rights steps.
- I built the dc_sa_blinky_m0 project
- I change the settings of the dc_sa_blinky (for M4) project (Settings->tool Settings->MCU Linker->Multicore) where I check off the M0APP slave, I do not change Master memory (I tried both MFlashA512 and RAM2 nevertheless) and I define the slave application with the image built for the dc_sa_blinky_m0 program.
So this should link the slave M0 to the master M4? Do I forget another step, another configuration?
Then I launch the debug but I end in the HardFault_Handler another time, just after checking if the image was correctly loaded (after line 217 of the m0_img_loader from the dc_sa_blinky example.
So could someone help me there and tell me what I’m doing wrong.
(I get the same errors for the dc_freertos_blinky project)
Labels (1)
0 Kudos
Reply
13 Replies

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by iaun.hma67 on Tue Oct 06 01:52:45 MST 2015
hello
I am a beginner in lpc4337 and trying to make a project by this processor...
I want to blink the LEDs connected to P6.9 & P6.10 with core M0 and blink the other tow LEDs connected to P6.11 & P6.12 with coreM4.
I am working by keil 5 and registers without using of CMSIS standard function. my programmer is j_link and I have work on OPEN18xx/43xxB1 training board(fabricated by Wave Share).
by using your post and others I don't understand how to configure my program :((
I write this code for core M0 :

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <LPC43xx.h>

void delay_ms(int Del)
{
long int i;
for(i=0;i<Del*8000;i++);
}
int main(void)
{

//LED4 P6.9   GPIO3[5]  FUNC0
LPC_SCU->SFSP6_9=0x00000028;
LPC_GPIO_PORT->DIR[3] |= (1 <<5);
  //LED3 P6.10  GPIO3[6]  FUNC0 
LPC_SCU->SFSP6_10=0x00000028;
LPC_GPIO_PORT->DIR[3] |= (1 <<6);
while (1)
{                          
LPC_GPIO_PORT->SET[3]=1<<5;       // GPIO3[5] :   (LED D4)
delay_ms(500);
LPC_GPIO_PORT->SET[3]=1<<6;       // GPIO3[6] :   (LED D3)
delay_ms(500);
LPC_GPIO_PORT->CLR[3]=1<<5;       // GPIO3[5] :   (LED D4)
delay_ms(500);
LPC_GPIO_PORT->CLR[3]=1<<6;       // GPIO3[6] :   (LED D3)
delay_ms(500);
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and setting for M0 core like this:

image1

image2

image3

image4

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

and this code for core M4 in the other project:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
#include <LPC43xx.h>

void delay_ms(int Del)
{
long int i;
for(i=0;i<Del*8000;i++);
}

/* Boot the M0 core */
void lpc43xx_m0_boot(void)
{
/* Make sure the M0 core is being held in reset via the RGU */
LPC_RGU->RESET_CTRL1 = (1 << 24);
}



int main(void)
{


//LED2 P6.11  GPIO3[7]  FUNC0
LPC_SCU->SFSP6_11=0x00000028;
LPC_GPIO_PORT->DIR[3] |= (1 <<7);
//LED1 P6.12  GPIO2[8]  FUNC0
LPC_SCU->SFSP6_12=0x00000028;
LPC_GPIO_PORT->DIR[2] |= (1 <<8);

while (1)
{                          
LPC_GPIO_PORT->SET[3]=1<<7;       // GPIO3[7] :   (LED D2)
delay_ms(1000);
LPC_GPIO_PORT->SET[2]=1<<8;       // GPIO2[8] :   (LED D1)
delay_ms(1000);
LPC_GPIO_PORT->CLR[3]=1<<7;       // GPIO3[7] :   (LED D2)
delay_ms(1000);
LPC_GPIO_PORT->CLR[2]=1<<8;       // GPIO2[8] :   (LED D1)
delay_ms(1000);

}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and setting for M0 core like this:

image5

image6

image7

image8

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i should say that i use wizard project in keil 5 to make these tow project  & i want to run all of these project by using any new heeder file or lib :~
i want to do all the necessary work like releasing M0 core from reset just by basic registers.
i read all of corresponsive post in this site and in internet, but i just confused !!!
thank you for attention
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Wed Jul 09 03:02:48 MST 2014

Quote: mrabbasi61

starblue, doesn't it affect the performance?
I think when one core is accessing the shared memory, it may avoid the other core from accessing, is it true?


Yes, but that cannot be avoided for shared data. In my case it is not a problem, because there is not that much data (some values for A/D and D/A converters).

I use separate memories for the local data of the M4, local data of the M0, and for the shared data. In that way the conflicts are minimized.

Jürgen
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrabbasi61 on Wed Jul 09 02:09:11 MST 2014
thank you all for your help,

starblue, doesn't it affect the performance?
I think when one core is accessing the shared memory, it may avoid the other core from accessing, is it true?

in my case, I want to update the screen of an RGB Graphic LCD by M0 core. what is your recommendation for this?
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Tue Jul 08 07:32:57 MST 2014
The IPC described in the manual is just one way to communicate via shared memory.

In my project I don't use it. Instead I have a struct at a fixed address, which contains the variables shared between the cores. For example, to send an acknowledge a simple boolean flag would suffice.

Of course, you need to be aware of concurrency issues and declare your variables volatile or use memory barriers as appropriate.
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Jul 08 04:15:39 MST 2014
You need IPC (inter processor communication). Described in Chapter 2 of the User Manual.

Also, see the Forums post:
http://www.lpcware.com/content/forum/problem-ipc-4357
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrabbasi61 on Tue Jul 08 03:54:27 MST 2014
hi,
thank you very much Support,
yes, actually I had not load the firmware into the correct place for M0,
and now I have my first dual core Blinky application running. Thnks a lot for your help, support and concern.

Also,
I want to know that is it possible to return a value or an acknowledge after successfully running a function from one core to another?
maybe it is already done, but I couldn't find it in the code.
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Jul 07 01:22:00 MST 2014
So that error would suggest that you have not programmed the M0 image into the flash?

If you are using the LPCOpen examples, then you need to make sure that you follow the instructions in the FAQ previously provided to you

http://www.lpcware.com/content/faq/how-run-multicore-examples-provided-lpcopen-lpc43xx-packages

in particular the need with the current versions to manually download the M0 image with these projects.

If you use your LPC-Link2 in 'redlink' mode rather than using the J-Link firmware, then if you follow the provided instructions, this should all "just work".

[With J-Link it should also work, but I haven't personally tried using this.]

To switch back to using 'redlink' on your LPC-Link2, disconnect the probe from USB,  remove JP1, then connect to USB again.

http://www.lpcware.com/lpclink2

Regards,
LPCXpresso Support
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrabbasi61 on Mon Jul 07 00:21:08 MST 2014
it was a Dev. Board for LPC4357 from Waveshare, name of the board is Open43xxE2,
I use LPCXpresso toolchain, and LPCOpen platform, and LPCLink2 debug probe. I also use JLink in order to loaD the program on processor.
I connect a cable to UART0, and on PC I open one Hyper Terminal. when I restart the board, I see the following output on PC hyper terminal application.

ERROR: Unable to find signature1 of M0 Image at 0x1b000010
ERROR: Boot failure!!
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Sun Jul 06 01:34:53 MST 2014
Which board? Which tools? Which debug probe?
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrabbasi61 on Sun Jul 06 01:20:18 MST 2014

Quote: lpcxpresso-support
Did you read the FAQ?
http://www.lpcware.com/content/faq/lpcxpresso/lpc43xx-multicore-apps

Also, you might try the examples in the product for the MCB4357. There is a simple dual-core blinky app. Without modification, it won't blink any LEDs (as it uses different GPIO's), but it does show a working M4 and working M0 application. Using LPCXpresso and LPC-Link2, you will also be able to debug both cores at the same time.



hi,
I am trying example dc_sa_blinky. but I got this on UART debug :

ERROR: Unable to find signature1 of M0 Image at 0x1b000010
ERROR: Boot failure!!


what is the problem?
Also, in Setting>Micro Controller Setting , Do I need to choose 4357-M4 ? or 4357-M0 ?

Thanks in advance.
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by floreste on Fri Jul 04 02:27:27 MST 2014
Though I still haven't run the provided examples, I have managed to create a new project with the help of this video from from minute 35 to minute 38.
So for now, I focuse on the new project.
Thank you for your answers, I'll let you know if I make any progress on the example matter.

Best regards
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sundarapandian on Fri Jun 27 09:15:26 MST 2014
Hi, If you are using LPCOpen examples I would suggest you to read this FAQ to understand how to program and run the code.
0 Kudos
Reply

1,711 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Jun 27 06:30:35 MST 2014
Did you read the FAQ?
http://www.lpcware.com/content/faq/lpcxpresso/lpc43xx-multicore-apps

Also, you might try the examples in the product for the MCB4357. There is a simple dual-core blinky app. Without modification, it won't blink any LEDs (as it uses different GPIO's), but it does show a working M4 and working M0 application. Using LPCXpresso and LPC-Link2, you will also be able to debug both cores at the same time.
0 Kudos
Reply