AP32 flash programming

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

AP32 flash programming

2,830 次查看
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Mon May 23, 2005 6:43 pm    
 
Hello people. I am working with an 68hc908ap32, I am trying to write to the flash memory in order to use it as an non volatile memory, but since this microcontroller has a mask error, the routines to do it so, has to be reinserted in the code. everywhere are examples of such routines in assembler, but i cannot find it in C language, I am compiling with metrowerks codewarrior, wich supports assembler, but is not the same as CASM, it does not support some implementation of the codes, So my solution could be one written in c, or to rewrite the code in assembler, compatible with the codewarrior. also I am looking for a good delay routine written in C. wich can define diferent input clocks. Regards.
 
Posted: Wed May 25, 2005 11:00 am    
 
Hello, Have a look to the AN2504 (On-Chip FLASH Programming API for CodeWarrior Software) Regards.
 
Posted: Wed May 25, 2005 9:16 pm    
 
I did exactly that. The thing is that on the errata of the ap64 is an issue with the rom resident routines regarding writing on eeprom. I have found a source code of these routines in assembler. The thing is are they going to work. Hope so. I am looking for a good delay function for hc08 written in C language. If anyone? Regards.
 
Posted: Fri May 27, 2005 9:51 am    
 
Hello, Well, using C for a delay function means you want to use the Timer ?! Writing a loop delay using C is not something to do. The compiler will decide how to translate it in ASM and it will greatly influence the timing.
 
Posted: Thu Jun 09, 2005 7:00 pm    
 
I believe the error in the AP chips has been corrected in the current mask set........ Posted: Mon Jun 27, 2005 11:14 am    
 
I´m trying to use internal flash (AP32) like eeprom to sabe some variables, but I can´t. What I´m doing wrong ?

 

Code:

typedef struct
{
   unsigned char BUS_SPD;
   unsigned char DATASIZE;
   unsigned int  START_ADDR;
   unsigned char DATAARRAY[15];
} TFILE_PTR;

TFILE_PTR FILE_PTR;

#define EE_READ     0xFD5B


static void Delay(void)
{
  unsigned int cnt = 65500;
  while (cnt>0) cnt--;
}


void main(void)
{
word c;
unsigned char i;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/




   serialAux_SendBlock("\n\rR1",4,&c);
   Delay();      
   for(i=0;i<15;i++)
   {
      FILE_PTR.DATAARRAY[i]='R';   
   }
   Delay();
   serialAux_SendBlock(&FILE_PTR.DATAARRAY[0],15,&c);
   Delay();
   serialAux_SendBlock("\n\rR2",4,&c);
   Delay();   
      
   FILE_PTR.BUS_SPD = 32;
   FILE_PTR.DATASIZE = 12;
   FILE_PTR.START_ADDR = 0x0A00;
   
   asm
   {
      LDHX FILE_PTR.BUS_SPD
      JSR EE_READ
   }

   serialAux_SendBlock("\n\rR3",4,&c);
   Delay();
   serialAux_SendBlock(&FILE_PTR.DATAARRAY[0],15,&c);
   Delay();
   serialAux_SendBlock("\n\rR4",4,&c);
      

  for(;:smileywink:{
 
  }
}


Posted: Mon Jun 27, 2005 12:04 pm    

Hi,

I don't see where you do programming in this code.
I can see you're sending block of data which seems like text to a console, but where do you actually write into the Flash ?
Is it that I drink too much decaf' and should go back to the real expresso

Cheers,

Posted: Mon Jun 27, 2005 12:55 pm    

hi alban,

On really I´m not writting anything, this is the problem I´m still trying to read.

This is the code (to read):

FILE_PTR.BUS_SPD = 32;
FILE_PTR.DATASIZE = 12;
FILE_PTR.START_ADDR = 0x0A00;

asm
{
LDHX FILE_PTR.BUS_SPD
JSR EE_READ
}


I think that I need some coofe, or anything more heavy!

Posted: Thu Jun 30, 2005 11:17 am    

Got your PM... Quite busy at work.

You routines mentions a jump to EE_READ routine but I don't see it declared anywhere.
To read the memory, I don't think you care about the Bus Speed or anything like that! You just read with the addresses.
Let's take an example, you want to copy block of EEPROM $XX10-$XX20 to RAM $X300-$X310, you just need a loop routines doing a read-write.

Code:
#define TABLE_RAM_BASE 0xX300
const tVECTORS TableEepromBase = {0,0,0,0,0, 0,0,0,0,0} @ 0xXX10;

rubbish_returned = memcpy((unsigned char*)TABLE_RAM_BASE,
                      &TableEepromBase, 10);

memcopy is a basic C function. You can get help on its parameters in CodeW.


Do you see where I'm going ?



标签 (1)
0 项奖励
0 回复数