UROM

Efried

Active Member
Hello,
is it wise using UROM variables running out of VARs?
I can set UROM from a second WC8 and switch depending on the UROM on the first WC8.
Once in a while I will migrate to WC32 having more VARs, but need to do in the middle of data logging...
 
thanks
 
 
 
Efried said:
is it wise using UROM variables running out of VARs?
I can set UROM from a second WC8 and switch depending on the UROM on the first WC8.
Once in a while I will migrate to WC32 having more VARs, but need to do in the middle of data logging...
 
UROM is stored in flash and as such has a limited number of write cycles.
If it's only infrequently-changing data it is probably ok, but be aware!
 
If you think you're running low on VAR/RAM, you might find doubling, triple or even quadruple use of vars is possible, depending on your data size.
Eg, it's easy to  store 3, 10-bit numbers in one memory by shifting.
 
Rossw would it be possible to give an example of storing 3,10-bit numbers in one memory by shifting please
 
pittom said:
Rossw would it be possible to give an example of storing 3,10-bit numbers in one memory by shifting please
 
Sure. There are so many different ways of doing it, I'll present a couple of alternatives.
If you have an older firmware without shift/rotate, here's a way of doing it with straight multiply/divides. This is brute-force ugly, but functional.
T1, T2, H1 packed into VAR2 (in decades, so you can visualize them without needing to calculate anything)
 
 

START
    MUL T1 1000000 var2
    MUL T2 1000 RAM1
    ADD RAM1 H1 ram1
    add ram1 var2 var2     #  VAR2 encoded with   111222hhh   (1=T1, 2=T2, h=Humidity)
 

    DIV VAR2 1000000 VAR8   # for the purposes of demonstration, we'll extract just T1 into VAR8

    DIV VAR2 1000000 RAM1  # for demonstration, decode just T2 into VAR7
    MUL RAM1 1000000 RAM1
    SUB VAR2 RAM1 ram1
    DIV RAM1 1000 VAR7

    DIV VAR2 1000 RAM1  # and finally H1 into VAR6
    MUL RAM1 1000 ram1
    SUB VAR2 RAM1 VAR6
END  

 
32 Bit Signed Vars
0   138140065  0   0   0   65   140   138
 
Temperature Sensors
13.8 C   14.0 C   unbound   unbound   unbound   unbound   unbound   unbound
                                 
Humidity Sensor
65 %
 
This should do a similar thing, allocating 10-bits for each, using ROT and ANDB
 
 
Code:
        ROTL T1 20 VAR2
        ROTL T2 10 RAM1
        ORB H1 RAM1 RAM1
        ORB VAR2 RAM1 VAR2   # bit-pack T1, T2 and H1 into bits 29-20, 19-10 and 9-0 respectivly

        ROTR VAR2 20 VAR8   # extract T1 into VAR8

        ROTR VAR2 10 RAM1
        ANDB RAM1 2047 VAR7  # extract T2 into VAR7

        ANDB VAR2 2047 VAR6   # extract H1 into VAR6
 
Back
Top