this commit won't work :(
authorBernhard Urban <lewurm@gmx.net>
Sun, 13 Dec 2009 21:37:19 +0000 (22:37 +0100)
committerBernhard Urban <lewurm@gmx.net>
Sun, 13 Dec 2009 21:43:52 +0000 (22:43 +0100)
basically he tries to flash a programm (here it is simpleprg) to
0xf4000 and erase it before. unfortunately it will fail -- maybe because
the pkernel is executed itself from there?!
however, the readme.txt of the flashdemo says no... dunno :(

pkernel/Makefile
pkernel/main.c
pkernel/uart.c

index 347d674a8484be17ce44f67b2201b77aba4b57c3..711c85d8a9d28bf569e9abd2bc1c89d0fd11a1f6 100644 (file)
@@ -45,7 +45,7 @@ CONVFLAGS = -cwno -Xdof
 
 DEFINES =
 
-TNAME = fuj
+TNAME = pkernel
 TARGET_MHX = $(TNAME).mhx
 TARGET = $(TNAME).abs
 DEPDIR = .deps
index 9f1cd287ed359a434bd12efe2bb9c6cd7b58f667..2a5cae2ed8ec3f30384125955fe10d2fcb7eea8d 100644 (file)
@@ -1,46 +1,13 @@
-/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
-/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
-/* ELIGIBILITY FOR ANY PURPOSES.                                             */
-/*                 (C) Fujitsu Microelectronics Europe GmbH                  */
-/*------------------------------------------------------------------------
-  MAIN.C
-  - description
-  - See README.TXT for project description and disclaimer.
-
-  06.10.06  1.01   UMa    changed includes
--------------------------------------------------------------------------*/
-
-/*************************@INCLUDE_START************************/
 #include "mb91465k.h"
 #include "vectors.h"
 #include "rlt.h"
 #include "flash.h"
-/**************************@INCLUDE_END*************************/
-
-/*********************@GLOBAL_VARIABLES_START*******************/
-/**********************@GLOBAL_VARIABLES_END********************/
-
-
-/*******************@FUNCTION_DECLARATION_START*****************/
-
-/*********************@FUNCTION_HEADER_START*********************
-*@FUNCTION NAME:    main()                                      *
-*                                                               *
-*@DESCRIPTION:      The main function controls the program flow *
-*                                                               *
-*@PARAMETER:        none                                        *
-*                                                               *
-*@RETURN:           none                                        *
-*                                                               *
-***********************@FUNCTION_HEADER_END*********************/
-
 
 void main(void)
 {
        unsigned char error = 0;
        unsigned char global_error = 0; 
-       unsigned int i;
+       unsigned int i, baseaddr;
        
        /*      Enable Clock Monitor    */
        CSCFG_MONCKI = 1;
@@ -71,83 +38,25 @@ void main(void)
        Puts4(" \n\n");
        Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
 
-       /*      Do BlankCheck on Sector at 0xA0000      */
-       Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
-       error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
-       if( error == 1 )
-       {
-               Puts4("done.\n");
-       }
-       else
-       {
-               Puts4("failed.\n");
-       }
-               
-       /*      Show Current Content of 0xA0000 ... 0xA001F     */
-       i=0;
-       Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
-       while(i < 0x20)
-       {
-               Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4("  ");
-               i++;
-               if( (i % 0x10) == 0 ) Puts4("\n");
-       }
-       Puts4("\n");
-       
-       /*      SectorErase of FLASH Memory     0xA0000*/
-       Puts4("Sector Erase of 0xA0000 ... ");
-       error = FLASH_SectorErase(0xA0000);
-       error = FLASH_SectorErase(0xA0004);
-       if( error == 1 )
-       {
-               Puts4("done.\n");
-       }
-       else
-       {
-               global_error = 1;
-               Puts4("failed.\n");
-       }
-
-       /*      Do BlankCheck on Sectors at 0xA0000 */
-       Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
-       error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
-       if( error == 1 )
-       {
-               Puts4("done.\n");
-       }
-       else
-       {
-               global_error = 1;
-               Puts4("failed.\n");
-       }
-               
-       /*      Show Current Content of 0xA0000 ... 0xA001F     */
-       i=0;
-       Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
-       while(i < 0x20)
-       {
-               Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4("  ");
-               i++;
-               if( (i % 0x10) == 0 ) Puts4("\n");
-       }
-       Puts4("\n");
-       
-       /*      Write 0x55AA to 0xA0002 */
-       Puts4("Write 0x55AA to 0xA0002 ... ");
-       error = FLASH_WriteHalfWord(0xA0002,0x55AA);
-       if( error == 1 )
-       {
-               Puts4("done.\n");
-       }
-       else
-       {
-               global_error = 1;
-               Puts4("failed.\n");
+       i = 0;
+       baseaddr = 0xf4000;
+       for (; i <0x30; i+=4) {
+               error = FLASH_SectorErase(baseaddr + i);
+               Puts4("\nerased: ");
+               Puts4(error == 1 ? "[success] " : "[failed] ");
+               Puthex4(baseaddr + i, 6);
        }
 
-       /*      Write 0x33CC to 0xA0004 */
-       Puts4("Write 0x33CC to 0xA0004 ... ");
-       error = FLASH_WriteHalfWord(0xA0004,0x33CC);
+       Puts4("Write simpleprog to 0xf4000 ... ");
+       error = FLASH_WriteHalfWord(0xf4000,0x9b00);
+       error = FLASH_WriteHalfWord(0xf4002,0x0d4e);
+       error = FLASH_WriteHalfWord(0xf4004,0xcff1);
+       error = FLASH_WriteHalfWord(0xf4006,0x1601);
+       error = FLASH_WriteHalfWord(0xf4008,0x9b05);
+       error = FLASH_WriteHalfWord(0xf4010,0x04c7);
+       error = FLASH_WriteHalfWord(0xf4012,0xc106);
+       error = FLASH_WriteHalfWord(0xf4014,0x1656);
+       error = FLASH_WriteHalfWord(0xf4016,0xe0fb);
        if( error == 1 )
        {
                Puts4("done.\n");
@@ -158,12 +67,11 @@ void main(void)
                Puts4("failed.\n");
        }
                
-       /*      Show Current Content of 0xA0000 ... 0xA001F     */
        i=0;
-       Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
+       Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
        while(i < 0x20)
        {
-               Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4("  ");
+               Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4("  ");
                i++;
                if( (i % 0x10) == 0 ) Puts4("\n");
        }
@@ -182,19 +90,10 @@ void main(void)
 
        RLT_EnableInterrupt(0, 0);
                                        
-    while(1)                   /* endless loop */
+    while(1)
     {    
          
        HWWD_CL = 0;   
-       
-       /* feed hardware watchdog */
-       /* (Only for devices with hardware (R/C based) watchdog) */
-       /* The hardware (R/C based) watchdog is started */
-       /* automatically after power-up and can not be stopped */
-       /* If the hardware watchdog is not cleared frequently */
-       /* a reset is generated. */           
     }   
 }
 
-
-/********************@FUNCTION_DECLARATION_END******************/
index 0c528ddfc1922afe4be1ecf225b086b9d45cc8a9..738ff46f0fa30b572137845b052fb2491d10fbe6 100644 (file)
@@ -12,8 +12,8 @@ void InitUart4(void)
 {
   // Initialize UART asynchronous mode
   // BGR04 = 1666; //  9600 Baud @ 16MHz
-     BGR04 = 832;  // 19200 Baud @ 16MHz
-  // BGR04 = 416;  // 38400 Baud @ 16MHz
+  // BGR04 = 832;  // 19200 Baud @ 16MHz
+  BGR04 = 416;  // 38400 Baud @ 16MHz
 
   // BGR04 = 2083; //  9600 Baud @ 20MHz
   // BGR04 = 1041; // 19200 Baud @ 20MHz
@@ -29,13 +29,13 @@ void InitUart4(void)
   EPFR19 = 0x00;   // enable UART
 }
 
-void Putch4(char ch)         /* sends a char */
+void Putch4(unsigned char ch)         /* sends a char */
 {
   while (SSR04_TDRE == 0);    /* wait for transmit buffer empty        */
   TDR04 = ch;                 /* put ch into buffer                    */
 }
 
-char Getch4(void)            /* waits for and returns incomming char   */
+unsigned char Getch4(void)            /* waits for and returns incomming char  */
 {
   volatile unsigned ch;
 
@@ -125,5 +125,3 @@ void Putdec4(unsigned long x, int digits)
        Puts4(buf);                                     /* send string */
 }
 
-
-