News:

Let's find out together what makes a PIC Tick!

Main Menu

Data Tables

Started by keytapper, Mar 28, 2025, 01:51 PM

Previous topic - Next topic

keytapper

I'm trying to understand some inside of the compiler. I was expecting to read flash as it's possible to read a RAM position.

Dim timerValue As Byte                       ' Start time for period measurement
Dim tableSample as Flash8 = { 127,134,29,83,51,242,148,177,126,177,
                             148,242,51,83,29,134,127,121,225,172,
                             204,13,107,77,129,77,107,13,204,172,225,121}

timerValue = CRead AddressOf(tableSample)+5  ' this a bit cumbersome, less elegant

' maybe I may try to make a $define that will translate the above method

timerValue = tableSample[5]                  ' now it causes an error

One more question:
Do the enhanced MCUs of the Midrange family store one byte for every byte defined as flash or code8?
Ignorance comes with a cost

trastikata

MyResult = Cread8,16,24,32 Byte_Table[Offset]

 ;)

keytapper

Quote from: trastikata on Mar 28, 2025, 02:26 PMMyResult = Cread8,16,24,32 Byte_Table[Offset]
Is a MCU type dependency?
I was try with 12F1840 MCU, perhaps 18F family doesn't make glitches.
On the other hand is it simple to make a macro?

$define read_table(x,y) (Cread8{16|24|32} addressOf(x)+y)It probably fail because x is the variable name
Ignorance comes with a cost

flosigud

timerValue = CRead8 tableSample[offset]
If you test code in a meta macro and it fails the error messages, if any, won't be meaningful.

keytapper

Quote from: flosigud on Mar 29, 2025, 04:36 PMtimerValue = CRead8 tableSample[offset]
This remain within the source made, the variable is tied up to its name.
I didn't try the mentioned macro, I presume just a silly thought, because I suppose we cannot pass in a variable name.
Ignorance comes with a cost