Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

LPC2146 IAP Erase & Write not working.

LPC2146 IAP Erase & Write not working.

2005-12-08 by mark_dell555

Hi, I'm having a problem erasing the flash with IAP calls on my
lpc2146.  I'm making calls to the IAP, and get the chip id fine from
the IAP.  Next I make a call to Prepare the flash for writing (50d),
and I get CMD_SUCCESS (0d) as the response.  Then I make a call to
Erase to wipe some sectors where I know I have data (min sector=5  max
sector=14), and again i get CMD_SUCCESS (0d), but the IAP hasnt erased
anything, and has only spent 300us completing both those calls.

I'm running in User mode, I have interrupts enabled, and all the
handlers for the interrupts are in RAM.  Is there something I am
missing? Is there anything else I can try?

Any help is always greatly appriciated.

Cheers,
Mark

Re: [lpc2000] LPC2146 IAP Erase & Write not working.

2005-12-08 by Richard Duits

The only thing I can think of is that the IAP routines may not work in 
user mode. Try switching to system mode before calling an IAP routine.

Richard.


mark_dell555 wrote:
Show quoted textHide quoted text
> Hi, I'm having a problem erasing the flash with IAP calls on my
> lpc2146.  I'm making calls to the IAP, and get the chip id fine from
> the IAP.  Next I make a call to Prepare the flash for writing (50d),
> and I get CMD_SUCCESS (0d) as the response.  Then I make a call to
> Erase to wipe some sectors where I know I have data (min sector=5  max
> sector=14), and again i get CMD_SUCCESS (0d), but the IAP hasnt erased
> anything, and has only spent 300us completing both those calls.
>
> I'm running in User mode, I have interrupts enabled, and all the
> handlers for the interrupts are in RAM.  Is there something I am
> missing? Is there anything else I can try?
>
> Any help is always greatly appriciated.
>
> Cheers,
> Mark

Re: LPC2146 IAP Erase & Write not working.

2005-12-08 by mark_dell555

Tried SVC mode, with interrupts both enable and disabled.  The result
is still the same.

--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
Show quoted textHide quoted text
>
> The only thing I can think of is that the IAP routines may not work in 
> user mode. Try switching to system mode before calling an IAP routine.
> 
> Richard.
> 
> 
> mark_dell555 wrote:
> 
> > Hi, I'm having a problem erasing the flash with IAP calls on my
> > lpc2146.  I'm making calls to the IAP, and get the chip id fine from
> > the IAP.  Next I make a call to Prepare the flash for writing (50d),
> > and I get CMD_SUCCESS (0d) as the response.  Then I make a call to
> > Erase to wipe some sectors where I know I have data (min sector=5  max
> > sector=14), and again i get CMD_SUCCESS (0d), but the IAP hasnt erased
> > anything, and has only spent 300us completing both those calls.
> >
> > I'm running in User mode, I have interrupts enabled, and all the
> > handlers for the interrupts are in RAM.  Is there something I am
> > missing? Is there anything else I can try?
> >
> > Any help is always greatly appriciated.
> >
> > Cheers,
> > Mark
>

RE: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2005-12-08 by Joel Winarske

This code works:
http://groups.yahoo.com/group/lpc2000/files/EE_demo.zip
(code here modified from original)

unsigned int command_iap[5];
unsigned int result_iap[3];
unsigned char memmap;

__disable_interrupt();
memmap = MEMMAP;        // get current memory map
MEMMAP = MEMMAP_FLASH;  // map User Flash into low 64 bytes

command_iap[0]=50;      //prepare sectors for erase
command_iap[1]=EE_SEC_L;
command_iap[2]=EE_SEC_H;
iap_entry=(IAP) IAP_LOCATION;
iap_entry(command_iap,result_iap);

command_iap[0]=52;      //erase sectors
command_iap[1]=EE_SEC_L;
command_iap[2]=EE_SEC_H;
command_iap[3]=EE_CCLK;
iap_entry=(IAP) IAP_LOCATION;
iap_entry(command_iap,result_iap);

command_iap[0]=53;      //blankcheck sectors
command_iap[1]=EE_SEC_L;
command_iap[2]=EE_SEC_H;
iap_entry=(IAP) IAP_LOCATION;
iap_entry(command_iap,result_iap);

MEMMAP = memmap & 0x03; // restore the memory map
__enable_interrupt();


Joel

Re: LPC2146 IAP Erase & Write not working.

2005-12-09 by mark_dell555

Thanks for the snippet, I tried everything in this code and almost
gave up, then just by accident I noticed that erase has a 3rd
parameter (CCLK).  Cant believe I wasted 2 days trying to fix
something so simple.


Mark



--- In lpc2000@yahoogroups.com, "Joel Winarske" <joelw@i...> wrote:
Show quoted textHide quoted text
>
> This code works:
> http://groups.yahoo.com/group/lpc2000/files/EE_demo.zip
> (code here modified from original)
> 
> unsigned int command_iap[5];
> unsigned int result_iap[3];
> unsigned char memmap;
> 
> __disable_interrupt();
> memmap = MEMMAP;        // get current memory map
> MEMMAP = MEMMAP_FLASH;  // map User Flash into low 64 bytes
> 
> command_iap[0]=50;      //prepare sectors for erase
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> command_iap[0]=52;      //erase sectors
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> command_iap[3]=EE_CCLK;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> command_iap[0]=53;      //blankcheck sectors
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> MEMMAP = memmap & 0x03; // restore the memory map
> __enable_interrupt();
> 
> 
> Joel
>

RE: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2005-12-09 by Joel Winarske

> Thanks for the snippet, I tried everything in this code and almost
> gave up, then just by accident I noticed that erase has a 3rd
> parameter (CCLK).  Cant believe I wasted 2 days trying to fix
> something so simple.

You bet!

Joel

Re: LPC2146 IAP Erase & Write not working.

2006-01-04 by gaquaycalifornia

Hi Joe,
I got it work but as soon as I turn on any interrupt it hang.
do you have some thing that works already?
thanks

--- In lpc2000@...m, "Joel Winarske" <joelw@i...> wrote:
Show quoted textHide quoted text
>
> This code works:
> http://groups.yahoo.com/group/lpc2000/files/EE_demo.zip
> (code here modified from original)
> 
> unsigned int command_iap[5];
> unsigned int result_iap[3];
> unsigned char memmap;
> 
> __disable_interrupt();
> memmap = MEMMAP;        // get current memory map
> MEMMAP = MEMMAP_FLASH;  // map User Flash into low 64 bytes
> 
> command_iap[0]=50;      //prepare sectors for erase
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> command_iap[0]=52;      //erase sectors
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> command_iap[3]=EE_CCLK;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> command_iap[0]=53;      //blankcheck sectors
> command_iap[1]=EE_SEC_L;
> command_iap[2]=EE_SEC_H;
> iap_entry=(IAP) IAP_LOCATION;
> iap_entry(command_iap,result_iap);
> 
> MEMMAP = memmap & 0x03; // restore the memory map
> __enable_interrupt();
> 
> 
> Joel
>

RE: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2006-01-04 by Joel Winarske

I have example project for IAR.  It uses the code as listed below.

Joel
Show quoted textHide quoted text
> Hi Joe,
> I got it work but as soon as I turn on any interrupt it hang.
> do you have some thing that works already?
> thanks
> 
> --- In lpc2000@yahoogroups.com, "Joel Winarske" <joelw@i...> wrote:
> >
> > This code works:
> > http://groups.yahoo.com/group/lpc2000/files/EE_demo.zip
> > (code here modified from original)
> >
> > unsigned int command_iap[5];
> > unsigned int result_iap[3];
> > unsigned char memmap;
> >
> > __disable_interrupt();
> > memmap = MEMMAP;        // get current memory map
> > MEMMAP = MEMMAP_FLASH;  // map User Flash into low 64 bytes
> >
> > command_iap[0]=50;      //prepare sectors for erase
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > command_iap[0]=52;      //erase sectors
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > command_iap[3]=EE_CCLK;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > command_iap[0]=53;      //blankcheck sectors
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > MEMMAP = memmap & 0x03; // restore the memory map
> > __enable_interrupt();
> >
> >
> > Joel
> >
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
>

Re: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2006-01-04 by Sten

Joel Winarske wrote:
> I have example project for IAR.  It uses the code as listed below.
> 
> Joel
> 
> 
> 
>>Hi Joe,
>>I got it work but as soon as I turn on any interrupt it hang.
>>do you have some thing that works already?
>>thanks
>>

I read something in the manual, that interrupts _must_ be turned off
while using IAP routines. Otherwise it may result in unexpected behaviour.


-- 
/************************************************
 Do you need a tiny and efficient real time
 operating system (RTOS) with a preemtive
 multitasking for LPC2000 or AT91SAM7?

   http://nanortos.net-attack.de/

 Or some open-source tools and code for LPC2000?

   http://www.net-attack.de/

************************************************/

RE: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2006-01-05 by Tong Le

Hi Joel,
  My MEMMAP  EQU 0XE01FC040
  but I can't find my MEMMAP_FLASH.
  is this something you define? right
  if so I am using the LPC2138, therefore it should be the beginning of my code?
  Thanks
  

Joel Winarske <joelw@...> wrote:
  I have example project for IAR.  It uses the code as listed below.

Joel


> Hi Joe,
> I got it work but as soon as I turn on any interrupt it hang.
> do you have some thing that works already?
> thanks
> 
> --- In lpc2000@yahoogroups.com, "Joel Winarske" <joelw@i...> wrote:
> >
> > This code works:
> > http://groups.yahoo.com/group/lpc2000/files/EE_demo.zip
> > (code here modified from original)
> >
> > unsigned int command_iap[5];
> > unsigned int result_iap[3];
> > unsigned char memmap;
> >
> > __disable_interrupt();
> > memmap = MEMMAP;        // get current memory map
> > MEMMAP = MEMMAP_FLASH;  // map User Flash into low 64 bytes
> >
> > command_iap[0]=50;      //prepare sectors for erase
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > command_iap[0]=52;      //erase sectors
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > command_iap[3]=EE_CCLK;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > command_iap[0]=53;      //blankcheck sectors
> > command_iap[1]=EE_SEC_L;
> > command_iap[2]=EE_SEC_H;
> > iap_entry=(IAP) IAP_LOCATION;
> > iap_entry(command_iap,result_iap);
> >
> > MEMMAP = memmap & 0x03; // restore the memory map
> > __enable_interrupt();
> >
> >
> > Joel
> >
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 





  SPONSORED LINKS 
        Microprocessor   Microcontrollers   Pic microcontrollers     8051 microprocessor 
    
---------------------------------
  YAHOO! GROUPS LINKS 

    
    Visit your group "lpc2000" on the web.
    
    To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
    
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

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

  


		
---------------------------------
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less

[Non-text portions of this message have been removed]

RE: [lpc2000] Re: LPC2146 IAP Erase & Write not working.

2006-01-05 by Joel Winarske

> Hi Joel,
>   My MEMMAP  EQU 0XE01FC040
>   but I can't find my MEMMAP_FLASH.
>   is this something you define? right
>   if so I am using the LPC2138, therefore it should be the beginning of my
> code?

#define MEMMAP         (*(volatile unsigned long *) 0xE01FC040)
#define MEMMAP_FLASH  1                 // Interrupt Vectors in Flash


Joel

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.