Is mbed codes compatible with LPC1769

02 Jul 2012

Hello,

I am working on the NxP LPC1769 and am hoping to reuse my code that I have written for the mbed.

1) Firstly, are the mbed codes compatible with the LPC?

2) If so, may I know how I can map the pins on the LPC1769, for example the P0[0], to an equivalent for the mbed code?

3) Lastly, can I simply compile the mbed code using the online compiler then use the LPCXpresso to flash the binary onto the LPC?

Thank you very much in advance!

02 Jul 2012

Yes code for the LPC1768 will download and work for the LPC1769. I have tested it with my own custom board and works well. You will need to convert the .bin output from online compiler to .hex with something like Bin2Hex program available online and then download with something like FlashMagic.

There are examples of using mbed to flash custom boards.....search on the mbed forum for "prototype to production" to get started.

02 Jul 2012

There some differences:

  • printf() will not work, because this uses the magic chip on the mbed (you can use pc.println, where pc is a Serial object)
  • network may not work (due to differences in the MAC chip)
  • local file system won't work, because it uses the magic chip on the mbed - use a SD card instead
03 Jul 2012

Thank you very much for your advice! May I know how i can map the pins on the LPC1769 to an mbed equivalent? For example, I will like to use pins P0[0] and P0[1] on the LPC1769 as UART3 pins, what pins should i use/type in the mbed code, Serial uart(p?, p?)

Thank you!

03 Jul 2012

The pin mapping is simple:

  • if it is a mbed pin, you can use the normal names (e.g. p10)
  • for all other pins like P0[0]/P0[1] it is P0_0 / P0_1

So you would write

serial uart(P0_0,P0_1)
03 Jul 2012

I have managed to compile and convert the BIN file to HEX. However, I have problems locating the COM port number for me device. I have tried looking it up in the device manager(I am using Windows 7), but it is not showing up there.

Just for clarification, I am using the bare LPC1769 board as it is. I am not sure what an ISP is, is it required in order to flash the LPC?

If not, what should I select under the Interface setting in Step 1?

Thank you very much for your help! =D

03 Jul 2012

If you use the LPCXpresso, the easiest way is to use the LPC-Link together with the CodeRed-IDE to transfer you file to the LPC1769. Otherwise you need either a JTAG adapter, or use the serial port. For that, see http://mbed.org/cookbook/Prototype-To-Hardware.

The LPCXpresso doesn't provide a serial-to-USB converter, so you either need:

  • such a converter (e.g. as a cable, or a FT232 board, or a CP2102 board)
  • a serial level converter (e.g. MAX3232) connected to the serial port you want to use
23 Jul 2012

Thank you very much Hendrik! I have managed to download codes from the mbed and flash it onto my LPC1769.

I am now trying to write a binary file to the LPC1769 and get the MCU to boot from the new firmware. I have found several forum threads on this, but when i tried to open a file to write or read, the program seems to be stuck. The following is the code i am using:

 #include "mbed.h"
 Serial *pUart_PC;
 Serial uart_PC(P0_2,P0_3);
 
 LocalFileSystem local("local");             // Create the local filesystem under the name "local"
 
 void InitUart() {
    uart_PC.baud(9600);
    uart_PC.format(8,Serial::None,1);
    uart_PC.printf("FILE IO test!!!\r\n");

    pUart_PC = &uart_PC;
}
 
 
 int main() 
 {
    InitUart();
    pUart_PC->printf("opening file\r\n");
    FILE *fp = fopen("/local/test.txt", "wb");  // Open "out.txt" on the local file system for writing
    
    if(fp ==NULL)
        pUart_PC->printf("Write File open fail: \r\n");
        
    else
    {
        pUart_PC->printf("write file OK: \r\n");
        fputc(0x99,fp);             
        fputc(0x15,fp);
        fclose(fp);                               
    }
    
    FILE *rp = fopen("/local/test.txt", "rb");
    
        if(rp ==NULL)
        pUart_PC->printf("Read File open fail: \r\n");
        
    else
    {
        pUart_PC->printf("read file OK: \r\n");
        fputc(0x99,fp);             
        fputc(0x15,fp);
        fclose(fp);                               
    }
    char c;
    c = fgetc(rp);
    pUart_PC->printf("Read from file: \r\n");
    pUart_PC->printf("%x ",c);
    c = fgetc(rp);
    pUart_PC->printf("%x ",c);
     
 } 

However, when i flash this mbed code onto my LPC7169, the program gets stuck when it is trying to open test.txt for writing right at the beginning.

Can someone please let me know where i went wrong and advise i could go about this?

Thank you very much in advance!

23 Jul 2012

The LocalFileSystem doesn't work on anything else then the mbed. It uses the 'magic chip' which makes the mbed visible as Flash drive. If you really need this, use an SD card (and one of the SD card file systems).

23 Jul 2012

Thank you for your quick reply.

I found this page that mentions how to write data onto the flash sectors using IAP, but I am not sure how to boot from the program that have been written, or perhaps boot from a specific sector.

http://mbed.org/users/okano/notebook/iap-in-application-programming-internal-flash-eras/?page=2#comment-1262

I have posted on that page asking the author how to boot the program that was written but he has not replied. Do you happen to have any idea on how to do this?

Thank you very much for your help!

23 Jul 2012

Writing the internal flash is not what the LocalFileSystem does. The latter one has a flash memory chip attached to the 'magic chip'. The mbed processor then communicates with this chip to read the data. For that, the mbed firmware is used, which gets compiled into every program you create on the mbed platform. But since your '1769 board has no such magic chip, it just hangs.

Wyh do you want to write to the internal flash of the LPC, and then start a program from there? If you want to upload your program, use one of the methods described above. If you you want to store additional data, use an external memory (e.g. a SD card).

23 Jul 2012

I wish to be able to upgrade/change the firmware on the LPC1769 wirelessly. I have a wireless device that I am connecting to the LPC using UART0, and I am sending the new binary file in segments of bytes.

I wish to write these bytes into the flash memory of the LPC, and then get the LPC to boot into the new firmware. I am also looking for a way to keep the old firmware in the flash memory, so that I can fall back in the event that the new firmware fails.

Is there a way to go about this?

Thank you very much!

24 Jul 2012

So you need a boot loader. There is an application note from NXP, maybe this help you (also with source for the USB boot loader). Also the Code Red) may help you.

There also seems to be a Ethernet boot loader from FlashMagic, but I can find only the LPC2000 version of it. But it might still help you.

If you have a wireless device, which can handle 2 additional signal lines (RTS and DTR preferrably) you can use the normal boot loader for the LPC1768 (connect DTR to reset, TX to P0.3, Rx to P0.2 and RTS to P2.10). There is also a cookbook.

24 Jul 2012

Hello Hendrik,

Thank you very much for your quick reply. Just to clarify, for the third method, I just have to send the UU-encoded data through the wireless device to the LPC1769 and pull the respective pins in the cookbook and I should be able to boot the LPC1769? Will I require any other hardware other than the LPC1769?

I have come across FreeRTOS, which I believe is a mini-OS that can be run on the LPC1769. Can FreeRTOS be used to handle the flashing? What i thought of was:

1) Run the current firmware using FreeRTOS 2) If there is a new firmware, send an interrupt to RTOS, which will then pull the new binary onto LPC1769 3) Flash the new binary onto a sector different from the current firmware 4) Reboot the FreeRTOS and tell it to run the newest firmware

May I know if this can be done?

Thank you very much for your time and help! I really appreciate it =D

25 Jul 2012

The boot loader is an internal program, which you normally don't touch (I think you can overwrite it via JTAG though). It has nothing to do with the program you are executing, so you don't program anything special. Yes, your wireless device should be enough to upload a program, provided you set the other pins correctly to start the boot loader.

I don't think it will be that easy to update a program on the fly - it would overwrite itself. You would need a schema where two versions of the program co-exist in the flash memory, and only one gets chosen at reset.

13 Dec 2013

Hello, I have mbed1768 codes on web-compilator and I´d like to program with this code my LPC1769 board. Is it even possible? or should I write new code using LPCExpresso?

Please for advice.

13 Dec 2013

Did you read this topic? Yes it is possible with the web compiler.

13 Mar 2017

hello! hi i am new student on embedded systems ,how to initilize clock , counters and time delay for LPC1769, pls give me reply.....

14 Mar 2017

Hi,

Here is a blinky example code for the LPCXpresso1769.

https://developer.mbed.org/users/MACRUM/code/LPCXpresso1769_blinky/

You can refer my modification for LPC1769@120MHz here:

https://developer.mbed.org/users/MACRUM/code/mbed-dev-lpcx1769/rev/341accce5a58

22 Sep 2019

can i simply take the mbed code and compile it in mcuxpresso to use the iap library or other library?