Matt/Rob

Thanks for feedback its very encouraging when one is stumped for ideas.

Have enclosed code designed to test the pseudo-array variable procedures 
supplied in sram_23k256.jal library. 

This code is clearly a cut down/modified version of Matt's 
16F877a_23k256.jal in the library. 

When I run this I observe the following:- 

sram_23k256_byte[] read and write ok irrespective of data written or read 

sram_23k256_word[] write ok irrespective of data written 

sram_23k256_word[] read can incorrectly read large values  that have been 
written correctly 

sram_23k256_dword[] write ok with many values of data

sram_23k256_dword[] write can incorrectly write large values of data  

sram_23k256_dword[] read can incorrectly read large values  that have been 
written correctly or incorrectly.

 

Incidently all these data read/writes are within page0 but since the 23k256 
is put in sequential mode early on in in the code

a read/write past a page boundary should not be an issue anyway 

Just for record I tried the 23k256 code with SPI mode forced 1,1 but got 
nowhere.

 

I keep looking at the 23k256.jal code but honestly cannot see how the code 
could produce this effect.

I would worry more that this is a compiler thing but I am not qualified to 
comment further. 

Also tried with 18LF4620, but experienced same problems.

 Kind Regards

Dave

 


On Thursday, 30 August 2012 16:11:14 UTC+1, mattschinkel wrote:
>
> Hi,
>
> Please post your full sample code here, I'll have a look. The word and 
> dword procedures haven't been used much, so I wouldn't be surprised if 
> there may be a bug in there somewhere. I assume the sample is working for 
> you? It does have a word/dword test in it.
>
> The code on justanotherlanguage.org tutorial should still be valid, but 
> use the sample in the package or on SVN. SVN is always the newest. 
>
> I believe you can use either SPI mode 00 or 11 with 23k256.   
>
> > var byte addr[4] at address 
>
> If the top bytes of this array are not used, the compiler will ignore them.
>
>
> Matt.
>
> On Thursday, August 30, 2012 9:51:08 AM UTC-4, PDSACAA wrote:
>>
>> Hello All 
>> I am working with 23k256 sram and seem to have found problems with 
>> 23k256_sram.jal include  library  procedures while executing 
>> 16F877a_23k256.jal sample. 
>>
>> In general all seems to work in principle , however:- 
>> when using the word and dword read/write array pseudo variable 
>> procedures with large data values  (I am afraid I cannot be more 
>> specific) say 0xDDFF  in the case of word or 0xAABBCCDD in the case of 
>> dword, problems seem to occur. 
>>
>> i.e. data seems to be either written to sram incorrectly or 
>> incorrectly read back again using the array pseudo variables. I have 
>> used alternative single byte read calls supplied in sram_23k256.jal to 
>> examine consecutive sram addresses and whereas things appear fine with 
>> most data values with other large data values problems show up. For 
>> example the 16F877a_23k256.jal sample as coded in the library I do not 
>> think gives the expected results. 
>>
>> The use of pseudo-variable arrays was discussed in jallist recently 
>> with some reservations, however Kyle confirmed that their use was now 
>> fully supported by the compiler. 
>> The code in 16F877a_23k256.jal sample as distributed only used 
>> constant values for the pseudo array indexes. I tried using assigned 
>> (word) variables for indexes but it didn't make any difference (no 
>> surprise there!!) 
>>
>> I have downloaded the 23k256_sram.jal  library module supplied in svn/ 
>> trunk/include/external/storage/ram assuming that this is the latest 
>> version. I am correct in this or will there be a later version? 
>>
>> I have sample code (which to be honest is really no more than a cut 
>> down version of 16F877a_23k256.jal ) which shows up problems but I am 
>> not sure how to submit this to JALLIB for examination. How does one 
>> post code to JALLIB forum? Does one just include it in the post? 
>>
>> I have examined the code in the pseudo variable procedures in 
>> 23k256_sram.jal and it looks good to me. There are some subtle lines 
>> of code that I find confusing but which I do not think can the cause 
>> of the problem. 
>>
>> One of these is the repeated use of :- 
>>
>> var byte addr[4] at address 
>>
>> where address is a word value and we clearly only require access to 
>> the 2 bytes addr[0] and addr[1]. Presumably addr[2] and addr[3] just 
>> point to other non-relevant storage locations but why is this done? I 
>> am obviously missing something here! 
>>
>> Can I also mention that Tutorial p104 says "23k256 uses SPI mode 
>> 1,1" ,it dosen't it uses mode 0,0 as borne out by code in 
>> 16F877a_23k256.jal. 
>> as provided by the  JAL distribution. 
>>
>> It also appears that the code in the tutorial differs from distributed 
>> 16F877a_23k256.jal to which it refers.  This is not necessarily a 
>> problem but the references on p101 and p104 to "const bit 
>> SRAM_23K256_ALWAYS_SET_SPI_MODE = TRUE" are confusing when in fact 
>> this is not the way that the SPI mode for the 23k256 is asserted in 
>> 16F877a_23k256.jal and other samples. I just think this is confusing 
>> for the novice and think the reference  would be better removed. 
>>
>> Can I ask members to check these issues and confirm or reject these 
>> problems I experience? 
>>
>> Many Thanks 
>> Dave Paxton 
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/jallib/-/hs1xB6l2OWMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

include 16f877a                    -- target PICmicro
--
-- This program assumes that a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
pragma target clock 20_000_000     -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC  HS              -- HS crystal or resonator
pragma target WDT  disabled        -- no watchdog
pragma target LVP  disabled        -- no Low Voltage Programming
--
enable_digital_io() -- disable all analog pins if any
_usec_delay (100_000) -- wait for power to stablilize

include delay

-- setup uart for communication
const serial_hw_baudrate  = 57600   -- set the baudrate
include serial_hardware
serial_hw_init()
-- some aliases so it is easy to change from serial hw to serial sw.
alias serial_write is serial_hw_write
alias serial_read is serial_hw_read
alias serial_data is serial_hw_data
alias serial_data_available is serial_hw_data_available


include print

include spi_master_hw         -- includes the spi library
-- define spi inputs/outputs
pin_sdi_direction = input    -- spi input
pin_sdo_direction = output   -- spi output
pin_sck_direction = output   -- spi clock
--
spi_init(SPI_MODE_11,SPI_RATE_FOSC_4) -- init spi, choose mode and speed
alias spi_master is spi_master_hw


-- setup 23k256 for external memory
-- setup chip select pin
ALIAS sram_23k256_chip_select             is pin_a5
ALIAS sram_23k256_chip_select_direction   is pin_a5_direction
-- initial settings
sram_23k256_chip_select_direction = output    -- chip select/slave select pin
sram_23k256_chip_select = high                -- start chip slect high (chip 
disabled)
-- initalize 23k256 in byte mode
alias sram_23k256_force_spi_mode is spi_master_hw_set_mode_00 -- always set spi 
mode to 0,0
include sram_23k256 -- setup Microchip 23k256 sram
sram_23k256_init(SRAM_23K256_SEQUENTIAL_MODE, SRAM_23K256_HOLD_DISABLE)  -- 
init 23k256 in sequential mode

-- procedure for sending 80 "-----------------" via serial port
procedure seperator() is
   serial_data = 13
   serial_data = 10
   const byte str3[] = 
"--------------------------------------------------------------------------------"
   print_string(serial_data, str3)
   print_crlf(serial_data)
end procedure

-- Send something to the serial port
seperator()             -- send "----" via serial port
var byte start_string[] = "23k256 TESTING STARTED"
print_string(serial_data,start_string)
seperator()

var word idx, word_data_out
var byte byte_data_out

for 32 using idx loop
sram_23k256_write(idx,0x00)   -- write 32 individual zero bytes at start of sram
end loop
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte   should see the 
zeros
end loop
print_crlf(serial_data)

-- example write then read from address 1
sram_23k256_write(1,0xAA)   -- write byte
sram_23k256_read (1, byte_data_out) -- read byte
print_byte_hex(serial_data,byte_data_out)   -- read/print byte
print_crlf(serial_data)

-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte   should see the 
AA at sram address 0x01
end loop
print_crlf(serial_data)

-- Example using 23k256 as a 32K Byte array (at array address 2)
sram_23k256_byte[2] = 0xBB   -- set array byte 2 to value 0xBB
byte_data_out = sram_23k256_byte[2]  -- read array dword 2, data should = 0xBB
print_byte_hex(serial_data,byte_data_out)   -- print return byte
print_crlf(serial_data)

-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte   should see the 
BB at sram address 0x02 as well
end loop
print_crlf(serial_data)

-- Example using 23k256 as a 16K Word array (at array address 4)
sram_23k256_word[4] = 0xAA99   -- set array byte 4 to value 0xAA99
word_data_out = sram_23k256_word[4]  -- read array word 4, data should = 0xAA99
print_word_hex(serial_data,word_data_out)   -- print return word
print_crlf(serial_data)


-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte   should see the 
AA99 at sram addresses 0x08 and 0x09 as well
end loop
print_crlf(serial_data)

-- Same as above butwith larger data value
sram_23k256_word[6] = 0xFF22   -- set array byte 4 to value 0xFF22
word_data_out = sram_23k256_word[6]  -- read array word 4, data should = 0xFF22
print_word_hex(serial_data,word_data_out)   -- print return word
print_crlf(serial_data)


-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte   should see the 
FF22 at sram addresses 0x0C and 0x0D as well
end loop
print_crlf(serial_data)

-- Example using 23k256 as a 8K dword array
var dword dword_data_in = 0x98765432,dword_data_out     -- {just being pedantic 
about
var word addr = 0x0005                                   -- {parameter types

sram_23k256_dword[addr] = dword_data_in -- set array dword 3 to value 0x98765432
dword_data_out = sram_23k256_dword[addr]      -- read array dword 3, data 
should = 0x98765432
print_dword_hex(serial_data,dword_data_out)   -- print return dword
print_crlf(serial_data)

-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte should see the 
98765432 at sram addresses 0x14-0x17 as well
end loop
print_crlf(serial_data)

dword_data_in = 0xAABBCCFF     -- {just being pedantic about
addr = 0x0007                                 -- {parameter types

-- Same again but with larger data value
sram_23k256_dword[addr] = dword_data_in -- set array dword 3 to value 0xAABBCCFF
dword_data_out = sram_23k256_dword[addr]      -- read array dword 3, data 
should = 0xAABBCCFF
print_dword_hex(serial_data,dword_data_out)   -- print return dword
print_crlf(serial_data)

-- send 32 byte map via serial port
for 32 using idx loop
sram_23k256_read(idx,byte_data_out)
print_byte_hex(serial_data,byte_data_out)   -- read/print byte should see the 
AABBCCFF at sram addresses 0x1C-0x1F as well
end loop
print_crlf(serial_data)

forever loop
end loop

Reply via email to