Hello, I use an mc9s12dp256, and my apllication needs to save some parameters in Flash. So I have make a program but it doesn't work, it chras my CPU. My config: CPU: m9s12DP256 (single chip) Fosc: 16MHz Fbus: 8MHz If someone foud an error or if I forget to configure some register: /* addr = 0xc000 */ int flah_program(buff, addr, size) int *buff, *addr; int size; { cpu->FCLKDIV = 0x49; cpu->FSTAT = PVIOL | ACCERR; for( ; size != 0; size--) { *addr = *buff; cpu->FCMD = 0x20; cpu->FSTAT = CBEIF; /* CPU crash here, bt the word is programmed */ if(!(cpu->FSTAT & (PVIOL | ACCERR)) { sci_printf("FLASH ERROR"); return 0; } while(!(cpu->FSTAT & CBEIF)); while(!(cpu->FSTAT & CCCIF)); adrr++; buff++; } return 1; } |
|
hcs12 flash
Started by ●April 17, 2003
Reply by ●April 17, 20032003-04-17
Sastien, Are you trying to program the data into the same 64K block you are executing code from? If so, that's what's causing the crash. Once a program or erase command is launched, the Flash block being programmed becomes unreadable until the command completes. Regards, Gordon Sastien wrote: > Hello, > > I use an mc9s12dp256, and my apllication needs to save some > parameters in Flash. > > So I have make a program but it doesn't work, it chras my CPU. > My config: > CPU: m9s12DP256 (single chip) > Fosc: 16MHz > Fbus: 8MHz > > If someone foud an error or if I forget to configure some register: > > /* addr = 0xc000 */ > int flah_program(buff, addr, size) > int *buff, *addr; > int size; > { > cpu->FCLKDIV = 0x49; > cpu->FSTAT = PVIOL | ACCERR; > > for( ; size != 0; size--) > { > *addr = *buff; > cpu->FCMD = 0x20; > cpu->FSTAT = CBEIF; /* CPU crash here, bt the word is > programmed */ > > if(!(cpu->FSTAT & (PVIOL | ACCERR)) > { > sci_printf("FLASH ERROR"); > return 0; > } > while(!(cpu->FSTAT & CBEIF)); > while(!(cpu->FSTAT & CCCIF)); > > adrr++; > buff++; > } > return 1; > } > -------------------- > > ">http://docs.yahoo.com/info/terms/ -- =============================================================== Gordon Doughman Ph: 937-438-6811 Motorola Semiconductor Fax: 937-434-7457 Field Applications Engineer Pager: 800-759-8352 Pin: 1304089 Suite 175 3131 Newmark Drive Miamisburg, OH 45342 Check out my HC12 book at: http://www.rtcbooks.com/programming.php |
Reply by ●April 17, 20032003-04-17
Yes, you can program the other 32k block instead it realy has to be
flash. laurent -----Original Message----- From: Gordon Doughman [mailto:] Sent: Thursday, April 17, 2003 3:58 PM To: Subject: Re: [68HC12] hcs12 flash Sastien, Are you trying to program the data into the same 64K block you are executing code from? If so, that's what's causing the crash. Once a program or erase command is launched, the Flash block being programmed becomes unreadable until the command completes. Regards, Gordon Sastien wrote: > Hello, > > I use an mc9s12dp256, and my apllication needs to save some > parameters in Flash. > > So I have make a program but it doesn't work, it chras my CPU. > My config: > CPU: m9s12DP256 (single chip) > Fosc: 16MHz > Fbus: 8MHz > > If someone foud an error or if I forget to configure some register: > > /* addr = 0xc000 */ > int flah_program(buff, addr, size) > int *buff, *addr; > int size; > { > cpu->FCLKDIV = 0x49; > cpu->FSTAT = PVIOL | ACCERR; > > for( ; size != 0; size--) > { > *addr = *buff; > cpu->FCMD = 0x20; > cpu->FSTAT = CBEIF; /* CPU crash here, bt the word is > programmed */ > > if(!(cpu->FSTAT & (PVIOL | ACCERR)) > { > sci_printf("FLASH ERROR"); > return 0; > } > while(!(cpu->FSTAT & CBEIF)); > while(!(cpu->FSTAT & CCCIF)); > > adrr++; > buff++; > } > return 1; > } > -------------------- > > ">http://docs.yahoo.com/info/terms/ -- =============================================================== Gordon Doughman Ph: 937-438-6811 Motorola Semiconductor Fax: 937-434-7457 Field Applications Engineer Pager: 800-759-8352 Pin: 1304089 Suite 175 3131 Newmark Drive Miamisburg, OH 45342 Check out my HC12 book at: http://www.rtcbooks.com/programming.php -------------------- ">http://docs.yahoo.com/info/terms/ |