EE_WRITE for 908LJ12

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

EE_WRITE for 908LJ12

4,784 Views
mohammed
Contributor III
Dear All
 
i tried to implement the emulated EEPROM with assembly and i made a small project just to insure that this part will work fine, but unfortunately it doesn't work; a message appears sys
 
Error: At location FC00 -
Error: Attempt to execute from unimplemented (--) ROM
 
i attached the project in case of any one interested
 
BTW, i take the EEPROM lines from the DataSheet of the 908LJ12
also if i write   org RAM   and ORG FLASH;;;;;;;;;;;;;;;;;;it gives me and error ((((Expression must be Absolute)))))
 
Regards
Hasan
Labels (1)
0 Kudos
Reply
15 Replies

2,103 Views
dkk
Contributor I

Hi, i've a proble with 908JL16: i've tried to use EE_write and EE_read for emulate eeprom by flash but it cause a reset. i'm using 10MHz xtal, and i've put 10 in BUS_SPD; anyone can help me? maybe i should disable COP?

0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello Hasan,
 
Are you working with the actual hardware, or with full chip simulation?  If the latter, the ROM base routines are not simulated and cannot be tested.
 
With respect to the ORG directives, the labels RAM and FLASH must be explicitly defined within the project.  It would appear this is not the case.  For the LJ12, the following definitions would apply -
RAM   equ $60
FLASH equ $C000
 
Regards,
Mac
 


Message Edited by bigmac on 2007-05-10 06:29 AM
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Hi bigMac,
thank you for your reply
 
am not familier with CW or LJ12, iam just a bigginner, although i have strong knowledge with PIC and ATMEL, any way iam just started using FreeScale controllers;
 
i know it's very simple to most of you, -who familier with HC08-
 
the situation is: iam using CW 5.1 i need to to simulate E2PROM, by assembly, how can i do this
 
please can you provide me steps, like
1-open .........
2- write this line...............etc
 
this is very important to me;
 
i have a suggestion:::::in PIC for example there a sub routines for popular elements;
 
like ADC have it's own subroutine.....etc,,,,,,,,,why we don't make that subroutines for ADC and RTC and LCD_DRIVER,,,,,,,,so when any one gonna use any one of them he will just place the subroutine in his project.
 
 
 
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Dear bigMac
 
as simple as it is
iam trying to put #01010101q to any specific address let's say  $FE00; by EE_WRITE
 
and then reading this number from the same address; by EE_READ
 
all this by assembly lang.
 
sorry for many question, but i don't know where to start;
 
thank you in advance
 
 
0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello Hasan,
 
I have had a look at your project file, and have found a number of problems with main.asm.  When assembled, a number of warning messages occurred.  To eliminate these warnings, the following corrections were needed -
  1. Two of the labels, FILE_PNTR and INITIALISATION, did not commence at column 1 - they must do so to be recognized as a label definition.
  2. The (RAM) section in which the data following FILE_PTR was to be placed was not defined.  I have placed it under MY_ZEROPAGE section.
  3. You had separated "main" and "Startup" labels - both these should refer to the same address where the code begins execution.

These changes should eliminate the warning messages, and permit debug to occur.  However there are some additional issues associated with the use of the ROM routines -

  1. You have set DATASIZE to a value of 15, but have not initialised DATAARRAY with the fifteen bytes to be written to flash.  This will need to be done.
  2. You currently have the EE_WRITE process continuously looping within the main loop.  In practice, this would cause the flash block that emulates EEPROM to wear out very rapidly, by exceeding the upper limit for erase/write cycles.  I have placed this code outside the main loop, for test purposes.
  3. It is apparent that you have been using full chip simulation for debug.  As I said previously, do not expect the ROM routine calls to work during simulation - these will work only with the actual hardware.

I have attached the corrected main.asm file, but does not include the initialisation of DATAARRAY.

 

Regards,

Mac

 

0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Hello BigMac;
 
thank you very much for the time you took to edit the code; really apretiated;
 
sorry for asking this question, but as you know i just started to learn FreeScale controllers - from 10 days only-
how can i test the EEPROM, how to verify the code,
 
let's say i want to write 01010101 and 10101010 to the data array; and make the data array size 2
 
1- i used to work with EEPROM in PIC ; I just do two things A) determine the the address B) determine the data
how can i determine these two things;  another meaning how can i write at the data array;
 
 
really appretiated your help,
0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello Hasan,
 
To work with two bytes only, firstly change the line of code to reflect the new DATASIZE value -
            MOV   #2, DATASIZE      ; 2 bytes of data to be written

There are many possibilities of placing write data into DATAARRAY, depending on where the data is to come from within the program.  In the following example, the data is directly loaded with immediate data -
 

            LDHX  #$55AA            ; Word value to be written
            STHX  DATAARRAY
            LDHX  FILE_PTR
            JSR   EE_WRITE

 

Since you cannot use simulation to test the operation of the ROM routines, the tests will need to be done using the actual MCU hardware.  The only way to determine the success or failure of the write process is to read back the data and test its validity.  Since  you have used the EE_WRITE routine, you must read the data using the EE_READ routine.

Since the operation of EE_READ will load the read data back into DATAARRAY, it may be advisable to zero DATAARRAY before calling the routine, so you can see that the code is really working.

 

             JSR   INITIALISATION
            LDHX  #0               ; Clear DATAARRAY
            STHX  DATAARRAY
            LDHX  FILE_PTR
            JSR   EE_READ

Regards,
Mac



Message Edited by bigmac on 2007-05-13 12:28 AM
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Dear BigMac;
 
thank youuuuuuuuu, very much, you realy good guy,
 
but i still facing a problem, i write down what you recommended, but in the ee_read the data array returns zero.  take alook on these lines
 
 BSR   INITIALISATION
         
            LDHX  #$55AA            ; Word value to be written
            STHX  DATAARRAY
            LDHX  FILE_PTR
            JSR   EE_WRITE
         
            JSR   INITIALISATION
            LDHX  #0               ; Clear DATAARRAY
            STHX  DATAARRAY
            LDHX  FILE_PTR
            JSR   EE_READ
           
             LDHX  DATAARRAY ;;;;;;;;; ; here iam trying to load the dataarray in the HX, 
             PSHH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  try to save H
             PULA  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; take the value of H and move it to A
             sta DDRB;;;;;;;;;;;;;;;;;;;;;;;;;; try to out the value of A to PORTB
             sta PTB;;;;;;;;;;;;;;;;;;;;;;;;;;;;; try to out the value of A to PORTB
 
last five lines, iam trying to verify that the data array contain the value of 55AA;
BUT after moving in HX, like i put ZEROS in HX,,,,,,,,,also in port B, it going to zero after sta PTB
 
please advice, where is the problem
BTW i use HW of Cyclon proand LJ12
 
regards
Hasan
0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello Hasan,
 
I think I have found the reason why your code is not working.  There is a basic error present in the code samples given in the data sheet for the LJ12, and of course, this was replicated in your code.  Unfortunately, I have missed the error up until now.
 
Anywhere the following statement occurs -
            LDHX  FILE_PTR
this should be altered to read -
            LDHX  #FILE_PTR
 
The incorrect statement actually sets H:X to the value contained in the first two bytes of the address FILE_PTR.  The corrected version provides the address of the first byte of the FILE_PTR block, which is the requirement of the ROM routines.
 
The error actually affects all ROM routines, not just EE_WRITE and EE_READ.  I have been referring to Rev 2.1 of the data sheet - I am not sure if there is a later revision.  I note that the data sheet for the LJ24 (also Rev 2.1) is correct.  Perhaps the error was originally corrected in one data sheet, but not the other.
 
Regards,
Mac
 
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Hello BigMac
 
i replaced ((LDHX  FILE_PTR)) with ((LDHX  #FILE_PTR))
 
but last time it was writting 0000 now it writes 255 255 in the
 
first time i load the data array,,, it hold in first byte 'U' 85 and the second byte contain 170;;;;;;
 
after reading, it holds first time 255 and second byte 255;
 
please advice;
0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello Hasan,
 
How are you monitoring the contents of the data array?  Are you able to debug whilst the MCU is in monitor mode, or do you rely on examining the output state of the Port B pins?
 
If debugging using monitor mode, you could directly check the contents of flash within the flash block used as EEPROM.  Keep in mind that the first eight bytes of the 128 byte block are used for control purposes.  So ignore these, and see if any later bytes contain the data that was supposedly written.  If all bytes still contain a value of $FF, this means that the EE_WRITE process did not succeed ($FF is the unprogrammed state).
 
If you were monitoring the Port B pins, the following code is potentially problematic -
 
            LDHX  DATAARRAY 
            PSHH
            PULA
            sta DDRB
            sta PTB
 
This is because you are writing the same value to PTB and DDRB.  If pullups happen to be enabled, or there are external pullup resistors, each pin will remain high, irrespective of the value written.  I will leave you to work out why this should be so.
 
Regards,
Mac
 
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Hello BigMac
 
am monitoring the registers by Debug mode,
the registers including EF00 are all  FF
 
and i run step by step in the EE_WRITE, the area of registers after specific instruction it goes to AD, then it goes to FF, that happened to all the area of registers;
 
i think you write the problem in EE_WRITE doesn't work,
but why,
 
thank you for your help,
0 Kudos
Reply

2,103 Views
bigmac
Specialist III
Hello,
 
You indicate that you have been single stepping through the EE_WRITE routine.  Some of the code within the routine will generate critical time delays for the flash write process.  Therefore, it is not a good idea to single step the ROM code.  In fact, single stepping this code would be a very bad idea since it would appear possible to damage a flash block if the internal high voltage remains active for an excessive duration (more than a few milliseconds).
 
When debugging, I suggest you place a breakpoint after the line containing JSR EE_WRITE, and execute EE_WRITE at normal speed.  It may also be a good idea to choose a new flash block, just in case the present one has been damaged.
 
Incidently, do you have the CPUSPD parameter correctly set for the bus frequency you are using.  If the frequency is other than 5 MHz, the parameter will need to be altered.
 
Regards,
Mac
 
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
Hi BigMac
 
thanks for the advice, to not step in ROM,
 
in debugger, iam using, 9.8MHz and devider by 2; - you know the first window when you begine debugging with P&E cyclon-
 
i used DF00 instead of EF00; but still the same,,,,,,,after EE_READ it reads 255 in the buffer
 
regards
hasan
0 Kudos
Reply

2,103 Views
mohammed
Contributor III
this is the All code
 
 
 
 
; Include derivative-specific definitions
            INCLUDE 'derivative.inc'
   FILE_PTR:
BUS_SPD DS.B 1 ; Indicates 4x bus frequency
DATASIZE DS.B 1 ; Data size to be programmed
START_ADDR DS.W 1 ; FLASH starting address
DATAARRAY DS.B 15 ; Reserved data array
EE_WRITE EQU $FC00
EE_READ EQU $FC03
FLASH_START EQU $EF00

; export symbols
            XDEF _Startup, main
            ; we export both '_Startup' and 'main' as symbols. Either can
            ; be referenced in the linker .prm file or from C/C++ later on
            XREF __SEG_END_SSTACK   ; symbol defined by the linker for the end of the stack
  

; variable/data section
MY_ZEROPAGE: SECTION  SHORT         ; Insert here your data definition
 

; code section
MyCode:     SECTION
main:
  INITIALISATION:
  MOV #20, BUS_SPD
  MOV #15, DATASIZE
  LDHX #FLASH_START
  STHX START_ADDR
  RTS
 
_Startup:
            LDHX   #__SEG_END_SSTACK ; initialize the stack pointer
            TXS
            CLI                     ; enable interrupts
 
mainLoop:
            ; Insert your code here
            NOP
  BSR INITIALISATION
  LDHX FILE_PTR
  JSR EE_WRITE
 
            feed_watchdog
            BRA    mainLoop
 
Message Edited by t.dowe on 2009-10-27 12:28 PM
0 Kudos
Reply