Hi Matthew

 

I tried your suggestion and sample.

I use the same large array of Mailyn with a ‘const byte’.

But it still does not work.

I send in the attachment the code and a capture with RealTerm.

You will see that with reading the sector nothing appears. I think the writing is the problem.

Writing byte for byte is going well and I removed that part code so you only see what is important.

Maybe there is a pragma problem or something else?

 

Regards,

Peter

 

Van: Matthew Schinkel
Verzonden: woensdag 22 februari 2023 03:14
Aan: jallib
Onderwerp: Re: [jallib] Re: problem with filling a sector buffer

 

Hi, this works from example 3, assuming the array is a constant (you didn't show the array in your example).

 

   const byte MARILYN[504] = {0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,
                              0x42,0x42,0x42,0x42}
                             
   -- fill the sector buffer with data
   for 504 using step1 loop
      sd_sector_buffer[step1] = MARILYN[step1]
   end loop
   -- write the sector buffer to sector 20
   sd_write_sector_address(20)

   -- read back the same sectors
   -- read sector 20 into the sector buffer
   sd_read_sector_address(20)
   -- now send it to the serial port
   for 504 using step1 loop                     -- loop till the end of the sector buffer
      serial_write (sd_sector_buffer[step1]) -- send each byte via serial port
   end loop

On Monday, February 20, 2023 at 11:05:35 PM UTC-5 Matthew Schinkel wrote:

Hi, ok so the original sample is working? I'll try what you have but one thing I see is that your loop is 512 but marilyn is only 504. The loop should only be the size of the array.

 

for 504 using teller loop


      sd_sector_buffer[teller] = marilyn[teller]
 end loop

Matt.

On Monday, February 20, 2023 at 6:37:02 PM UTC-5 [email protected] wrote:

Hi Matt

I know that and I tried it before I wanted to write an array to the SD card. 

It works perfect. 

The problem is how to write an array to the SD card. 

 

Regards,

Peter 



Op 21 feb. 2023 om 00:21 heeft Matthew Schinkel <[email protected]> het volgende geschreven:

Hi, have you tried another sd card? What PIC are you using?

 

Please try example 3 in the sample

 

;   --------------------------------------------------------------------------------
;   -- EXAMPLE #3 write to 2 sectors using a sector buffer at a address
;   -- user friendly and fastest.
;   --------------------------------------------------------------------------------
;   -- fill the sector buffer with data
;   for 512 using step1 loop                     -- loop till the end of the sector buffer
;      sd_sector_buffer[step1] = "B"             -- set each byte of data
;   end loop
;   -- write the sector buffer to sector 20
;   sd_write_sector_address(20)
;   for 512 using step1 loop                     -- loop till the end of the sector buffer
;      sd_sector_buffer[step1] = "C"             -- set each byte of data
;   end loop
;   -- write the sector buffer to sector 21
;   sd_write_sector_address(21)
;   --
;   -- read back the same sectors
;   -- read sector 20 into the sector buffer
;   sd_read_sector_address(20)
;   -- now send it to the serial port
;   for 512 using step1 loop                     -- loop till the end of the sector buffer
;      serial_write (sd_sector_buffer[step1]) -- send each byte via serial port
;   end loop
;   -- read sector 21 into the sector buffer
;   sd_read_sector_address(21)
;   -- now send it to the serial port
;   for 512 using step1 loop                     -- loop till the end of the sector buffer
;      serial_write (sd_sector_buffer[step1]) -- send each byte via serial port
;   end loop

 

Matt.

On Monday, February 20, 2023 at 12:12:04 PM UTC-5 [email protected] wrote:

Hi Matt
I think this is a question for you. You made a beautiful sample for writing to a sd card.
Every  start of the program I use the part of your lib to control the connection to the sd card.
I can write and read the sd card byte for byte. I use a bitmap image of Marilyn Monroe of 504 bytes.

The half of the next program works perfect:
var byte gegeven
var byte data
var word step1
var word teller

sd_start_write(50)          
   for count(marilyn) using teller loop
      sd_data_byte = marilyn[teller]
   end loop
sd_stop_write
This works perfect.


I also tried to write to the sd card with a 'sector buffer' because most arrays are larger.
But first the array of Marilyn. It can be written in one sector.
Attempt 1:
print_string(serial_data, "Writing to sector 100")
print_crlf(serial_data)

sd_start_write(100)        
--fill the sector buffer
   for 512 using teller loop
      sd_sector_buffer[teller] = marilyn[teller]
   end loop
--    write the sector buffer to sector 100
   sd_write_sector_address(100)
sd_stop _write

I also tried:
Attempt 2:

  sd_start_write(150)
        for 512 using step1 loop
           gegeven = marilyn[step1]
           sd_sector_buffer[step1] = gegeven
       end loop
-- write the sector buffer to the sd card
 sd_write_sector()
 sd_stop _write

Both attempts does not work.
I get rubbish when I read the sectors.
Can you tell me how I get it working.

Regards,
Peter

--
You received this message because you are subscribed to a topic in the Google Groups "jallib" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jallib/I1L0r6P-2xQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/8415623e-2bbb-424c-9498-cd9b3c3b651cn%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "jallib" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jallib/I1L0r6P-2xQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/dd7f03a9-9d77-42ea-8a9c-f08821a1fd3en%40googlegroups.com.

 

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/CE16F104-3322-4EFB-B7DB-9AEA90F12BE6%40hxcore.ol.
ÿ
Writing and reading a sector on a SD card
High capacity 
SD card successfully loaded!

--------------------------------------------------------------------------------
SD CARD information

--------------------------------------------------------------------------------
SD Card Size (bytes): 3158310912

SD Card Size (words): 1579155456

--------------------------------------------------------------------------------
Het bestand 'Marilyn' is 504 bytes groot
--------------------------------------------------------------------------------

 3 Writing a large array to sector 100 using a sector buffer
   Ready!
--------------------------------------------------------------------------------
 3a Writing a large array to sector 101 using a sector buffer
   Ready!

--------------------------------------------------------------------------------
 3 Here is sector 100
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--------------------------------------------------------------------------------
 3a Here is sector 101
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

--------------------------------------------------------------------------------

 3b Writing the large array of Marilyn to sector 180 using a sector buffer

--------------------------------------------------------------------------------
 3b Reading the large array of Marilyn of sector 180 using a sector buffer
ph8xøøøøøè@ 
ÀÀ€€ÀÀÀàðø~~þbcaÃÃÆ€€À8000øÿÿÿÿÿÿþô|üà÷w?>8°àà€Ç?
 000`ppüÿÃ>?ÿÿÿÿÿÿÿÿÿÿ° ðç÷ï 
ñøðüøüþ÷óóóóôæîÎüüøðàøüþÿÿÿÿÿÿÿÿÿߘâ„ÿÿý¿â÷gOÿÿÿþà€ƒÀ€Èæóÿÿÿÿÿÿÿÿÿÿÿøøþÿÿÿÿ?

--------------------------------------------------------------------------------
ph8xøøøøøè@ 
ÀÀ€€ÀÀÀàðø~~þbcaÃÃÆ€€À8000øÿÿÿÿÿÿþô|üà÷w?>8°àà€Ç?
 000`ppüÿÃ>?ÿÿÿÿÿÿÿÿÿÿ° ðç÷ï 
ñøðüøüþ÷óóóóôæîÎüüøðàøüþÿÿÿÿÿÿÿÿÿߘâ„ÿÿý¿â÷gOÿÿÿþà€ƒÀ€Èæóÿÿÿÿÿÿÿÿÿÿÿøøþÿÿÿÿ?

--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
 
SD CARD SAMPLE END. BYE BYE says PETER. 

--------------------------------------------------------------------------------

Attachment: 18f4455_sd_card.jal
Description: Binary data

Reply via email to