ISP over I2C - How?

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

ISP over I2C - How?

Jump to solution
2,833 Views
kbk1
Contributor II

Hi

I am working on a host application, which will program a LPC84x MCU via ISP by the I2C interface.

From the user manual I can read that the FAIM register default value is ISP over UART.

So, how do I access the FAIM registers, to change it to use ISP over I2C?

Isn't it possible to program the LPC84x by ISP/I2C without having to access the MCU registers first?

pastedImage_2.png

Thanks

Kaare

Labels (1)
Tags (3)
1 Solution
2,327 Views
kbk1
Contributor II

Thanks

The Flash Magic tool could be an easy way to do it.

In our case, we use a simple testprogram to test the board during production, and this program then contains the FAIM operation to enable I2C ISP.

u32FAIM_data = 0x68000000;
FAIMWrite( 0, (uint32_t)&u32FAIM_data);

I am quite sure that the FAIM register is "valid" from factory. This means that it uses UART as default ISP interface, and you need to change this to I2C.

br

Kaare

View solution in original post

0 Kudos
10 Replies
2,327 Views
brendonslade
NXP TechSupport
NXP TechSupport

The LPC84x devices will boot from I2C under certain conditions. You really need to refer to the flowchart from the UM to understand this. For a part with invalid (unprogrammed) FAIM, I2C ISP boot should be working but at fixed pin locations (PIO0_11 for SDA and PIO0_10 for SCL); if the FAIM has been programmed (is valid) then FAIM word 0 bit 30/31 will determine if I2C ISP will happen (as opposed to SPI or USART):

pastedImage_1.png

Also... just want to let viewers of this thread know that the free Flash Magic tool includes a FAIM programming utility. Under the ISP menu, open FAIM to view the current FAIM settings and write new values. .

This doesnt solve the original request, but might be preferable to using the SDK or Code Bundle examples to set up FAIM. Note that FAIM has a limited number of programming cycles, so be careful!

2,328 Views
kbk1
Contributor II

Thanks

The Flash Magic tool could be an easy way to do it.

In our case, we use a simple testprogram to test the board during production, and this program then contains the FAIM operation to enable I2C ISP.

u32FAIM_data = 0x68000000;
FAIMWrite( 0, (uint32_t)&u32FAIM_data);

I am quite sure that the FAIM register is "valid" from factory. This means that it uses UART as default ISP interface, and you need to change this to I2C.

br

Kaare

0 Kudos
2,327 Views
brendonslade
NXP TechSupport
NXP TechSupport

Hi Kare,

I'm 99% sure the manual ought to say "invalid or unprogrammed" for FAIM in table 3, section 3.4 - you shouldnt have to go through that extra step for new parts. I'm checking this with the design team now.

regards

Brendon

0 Kudos
2,327 Views
brendonslade
NXP TechSupport
NXP TechSupport

Ok - looks like the UM is correct ... you have to set FAIM to enable ISP mode over I2C (as Victor stated).

0 Kudos
2,327 Views
kbk1
Contributor II

OK, thanks.

It’s not a big deal in my situation, because we will need to program a test software for productions test anyway, and this is done by SWD/JTAG.

And this program simply calls the needed line of code to set the FAIM register.

Thanks

Kaare

0 Kudos
2,327 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Kaare,

Just to confirm, you are right. The FAIM register is valid from factory.

Regards,

Victor.

0 Kudos
2,327 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Kaare,

Regarding your questions please see my comments below.

So, how do I access the FAIM registers, to change it to use ISP over I2C?

I recommend you use the example FAIM_and_Clocks  of the CodeBundle for the LPC845, to change the value of the bits 31:30 of the FAIM word0. If you are using MCUXpresso IDE you can find the code bundle in the following path: C:\nxp\MCUXpressoIDE_10.2.1_795\ide\Examples\CodeBundles

Isn't it possible to program the LPC84x by ISP/I2C without having to access the MCU registers first?

Unfortunately no, it's not possible to program the LPC84x by I2C without changing the FAIM values first.

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,327 Views
kbk1
Contributor II

Hi

I have now tried out the FAIM example for the LPC845.

It is fairly simple, but i can't figure out how it works (and it does not work):

I use Rowley Crossworks, but I simple copied the necessary source to my main.c, to try it out:

When i call FAIMRead like this:

   FAIMRead( 0, (uint32_t)&read_data);

...it returns OK, but "read_data" is never updated by the call to FAIMRead.

Do I do anything wrong, or have I misunderstood something?

Here is the source I copied from the FAIM and clocks example:

struct sIAP
{
uint32_t cmd; // Command
uint32_t par[4]; // Parameters
uint32_t stat; // Status
uint32_t res[4]; // Result
};

static struct sIAP IAP;

// Pointer to ROM IAP entry functions
#define IAP_ENTRY_LOCATION 0x0F001FF1

enum eIAP_COMMANDS
{
IAP_PREPARE = 50, // Prepare sector(s) for write operation
IAP_COPY_RAM2FLASH, // Copy RAM to Flash
IAP_ERASE, // Erase sector(s)
IAP_BLANK_CHECK, // Blank check sector(s)
IAP_READ_PART_ID, // Read chip part ID
IAP_READ_BOOT_VER, // Read chip boot code version
IAP_COMPARE, // Compare memory areas
IAP_REINVOKE_ISP, // Reinvoke ISP
IAP_READ_UID, // Read unique ID
IAP_ERASE_PAGE, // Erase page(s)
IAP_READ_MISR=70,
IAP_READ_MISR_EX=73,
IAP_READ_PAGE_FAIM=80,
IAP_WRITE_PAGE_FAIM=81
};


// IAP Call
typedef void (*IAP_Entry) (uint32_t *cmd, uint32_t *stat);
#define IAP_Call ((IAP_Entry) IAP_ENTRY_LOCATION)

int FAIMRead (uint32_t adr0, uint32_t adr1)
{
IAP.cmd = IAP_READ_PAGE_FAIM; // READ FAIM PAGE
IAP.par[0] = adr0; // FAIM page number
IAP.par[1] = adr1; // Destination RAM address to store the read value
IAP_Call (&IAP.cmd, &IAP.stat); // Call IAP Command
if (IAP.stat) return (IAP.stat); // Command Failed

return (0); // Finished without Errors
}

0 Kudos
2,327 Views
kbk1
Contributor II

Ah !

It was the compiler optimization that made weird things happen (or not happen).

It works now, thanks !

We have decided to make a testprogram to download at production / test, which changes the FAIM to use I2C port for ISP interface.

It was not what we hoped, but it is doable.

br

Kåre

0 Kudos
2,327 Views
kbk1
Contributor II

Hi Victor 

Thanks for the fast response

But I don't like your answer :smileyhappy:

The example you point me to, shows how to change the FAIM from the LPC845 MCU itself.

This means that I have to have firmware in the MCU.

But, I don't want hat.

The reason to boot the LPC845 from a remote host via ISP, is to be able to boot the LPC845 directly from the factory.

I don't want to first program a dummy firmware into the chip, just to change the FAIM register setting.

As I read it, I have to use the UART to change the FAIM. This must be done in the factory, then.

And then I have to have the UART RX/TX exposed somehow.

And I must implement this in our production test facilities (which I hoped was not necessary...)

This was definitely not what I had in mind, and will complicate things a lot.

br

Kaare

0 Kudos