2010-07-26 11:46 AM
Accessing EEPROM with Cosmic compiler
2011-05-17 06:09 AM
2011-05-17 06:09 AM
2011-05-17 06:09 AM
2011-05-17 06:09 AM
OK - here's the file
# LINK COMMAND FILE AUTOMATICALLY GENERATED BY STVD: TOTALLY # IF AUTO MODE IS ENABLED, OR ONLY PARTIALLY WHEN AUTO MODE # IS DISABLED (see below). # # CAUTION: # # Sections delimited by <BEGIN ...> and <END ...> markers are # reserved for STVD: DO NOT MODIFY INSIDE. # # Manual modifications are allowed OUTSIDE these sections, WHEN # STVD ''auto'' MODE IS DISABLED (if ''auto'' mode is enabled, # modifications are lost). # When STVD ''auto'' mode is disabled, it is also possible to disable # the automatic update inside the reserved sections, by removing the # <BEGIN ...> and <END ...> markers of the corresponding section. # # Please refer to Cosmic User Manuals before any modification. # Note that errors in editing this file may have unpredictable results # when running STVD. # Segment configuration - section reserved for STVD #<BEGIN SEGMENT_CONF> # Segment Code,Constants: +seg .const -b 0x8080 -m 0x7f80 -n .const -it +seg .text -a .const -n .text # Segment Eeprom: +seg .eeprom -b 0x4000 -m 0x400 -n .eeprom # Segment Zero Page: +seg .bsct -b 0x0 -m 0x100 -n .bsct +seg .ubsct -a .bsct -n .ubsct +seg .bit -a .ubsct -n .bit -id +seg .share -a .bit -n .share -is # Segment Ram: +seg .data -b 0x100 -m 0x500 -n .data +seg .bss -a .data -n .bss #<END SEGMENT_CONF> # Startup file - section reserved for STVD #<BEGIN STARTUP_FILE> crtsi0.sm8 #<END STARTUP_FILE> # Object files list - section reserved for STVD #<BEGIN OBJECT_FILES> Debug\stm8s_clk.o Debug\stm8s_gpio.o Debug\stm8s_itc.o Debug\main.o Debug\stm8_interrupt.o Debug\stm8s_adc1.o Debug\stm8s_beep.o Debug\stm8s_exti.o Debug\stm8s_lcd.o Debug\stm8s_tim1.o Debug\stm8s_tim2.o Debug\stm8s_tim3.o Debug\stm8s_tim4.o Debug\timers.o Debug\utilities.o #<END OBJECT_FILES> # Library list - section reserved for STVD #<BEGIN LIBRARY_FILES> libfs0.sm8 libis0.sm8 libm0.sm8 #<END LIBRARY_FILES> # Interrupt vectors file - section reserved for STVD #<BEGIN VECTOR_FILE> +seg .const -b 0x8000 -k Debug\stm8_interrupt_vector.o #<END VECTOR_FILE> # Defines - section reserved for STVD #<BEGIN DEFINED_VARIABLES> +def __endzp=@.ubsct # end of uninitialized zpage +def __memory=@.bss # end of bss segment +def __startmem=@.bss +def __endmem=0x5ff +def __stack=0x7ff #<END DEFINED_VARIABLES>2011-05-17 06:09 AM
Hi,
I may have found the problem. I used Cstd in both the main.c module and also in another module of the program. There, I referred to it as: extern float Cstd; If I referred to it as 'extern @eeprom float Cstd', I got an error; I did not get an error if I referred to it as shown above. I only used it in one procedure there and have just found that, if I move that procedure into my main.c module where I declare all the variables, I no longer get a clink error. I have yet to determine if I can properly access Cstd in the program. It is only written to in a calibration procedure which is only used infrequently - but it is read in many different places in the project.2011-05-17 06:09 AM
2011-05-17 06:09 AM
There's nothing confidential about the project but it is, I think, too long to post
the whole thing. The section where I define the variables is: // global variables follow enum menu_t menu_mode; enum meas_t measurement_mode; float Cstd = 469.0e-12; float C1 = 509.0e-12; float L68 = 67.0e-6; float L1 = 68.0e-6; float Cx, Lx; long f1, f2; u8 s[16]; float rho; char cont; As above, it compiles, links and runs correctly. I get the clink error when I change the line with Cstd in it to the following: @eeprom float Cstd = 469.0e-12; Jim2011-05-17 06:09 AM
Hi again, OK, it compiles without errors and the program can read the value of Cstd when it is declared:
@eeprom float Cstd = 469.0e-12; It is read frequently in the program. However, in a calibration routine, if I try to change it with a statement like: Cstd = Cstd * 0.998; it does not change - I read it a few lines later and it has just got the same value as initialized in the statement which defines the variable. Jim2011-05-17 06:09 AM
Hi,
I've looked at the assembler code produced by the compiler for the brief code; it looks fine to me but it illustrates the problem. 352 ; 187 Cstd = Cstd * factor; 354 0141 ae0000 ldw x,#_Cstd 355 0144 cd0000 call c_ltor 357 0147 ae0075 ldw x,#L531 358 014a cd0000 call c_fmul 360 014d ae0000 ldw x,#_Cstd 361 0150 cd0000 call c_eewrl It looks like it reads the eeprom, does the multiplication and then tries to store it back in eeprom with the call to c_eewrl. However, when I run the program, the value in Cstd is NOT changed. Anyone have any suggestions? Jim