I've done some tests on the pata_hard_disk.jal library.

I've set up TMR0 to give an interrupt each second, output the value of 
bytes_read, and reset bytes_read to 0. Then some code like this was executed:

For word reads:

pata_hd_start_read(0)
forever loop
  pata_hd_read_data (in_b, in_a)
  bytes_read=bytes_read+2
end loop

For sector reads:

-- pata_hd_current_address=0
pata_hd_start_read(0)
forever loop
  pata_hd_read_sector()
  bytes_read=bytes_read+512
end loop

In pata_hd_read_sector() and pata_hd_read_sector2() I've inserted the still 
missing "asm nop" discussed in another thread. The tests were run on a 18f4520 
using INTOSC_PLL at 32MHz.

RESULTS:

pata_hd_read_data() yields approx. 317300 bytes per second. Code usage:3256, 
RAM usage: 129

pata_hd_read_sector() yields approx. 167500 bytes per second. Code usage:3500, 
RAM usage: 645

pata_hd_read_sector2() yields approx. 151000 bytes per second. Code usage:3772, 
RAM usage: 659

------------------------------------------------------
After removing large_array:

pata_hd_read_sector() yields approx. 581000 bytes per second. Code usage:3380, 
RAM usage: 638

Ok, the gain is not 400% but "just" 340%, but I think it's worth thinking about 
not using large_array as the sector buffer.

Here's the modified procedure: (removed some comments to make it readable)

---------------------------------------------------------------------------
-- read one entire sector
---------------------------------------------------------------------------
var dword pata_hd_last_sector
;const dword LARGE_ARRAY_3_SIZE = 512           -- choose number of array 
;const dword LARGE_ARRAY_3_VARIABLE_SIZE = 1    -- choose size of variables
;include large_array_3                          -- include the array
;alias pata_hd_sector_buffer is large_array_3   -- rename/alias the array 

var byte pata_hd_sector_buffer_lo[256] -- 256 low bytes
var byte pata_hd_sector_buffer_hi[256] -- 256 high bytes

var byte pata_hd_sector_count2 = 0
--
procedure pata_hd_read_sector() is
  var word count1
  pata_hd_word_count = 0

  if pata_hd_sector_count == 0 then                                      
    pata_hd_go_to_sector(pata_hd_sector_select,0)                        
    pata_hd_register_write(PATA_HD_COMMAND_REG,PATA_HD_READ_SECTORS)     
  end if

  pata_hd_data_request(PATA_HD_WAIT_READ) 

   for 256 using count1 loop -- NOTE: now "using count1"
     -- get the data trough the ide interface
     pata_hd_iord = high ^ PATA_HD_NO_INVERTER  -- start read pulse
     asm nop
     pata_hd_sector_buffer_hi[count1] = pata_hd_data_high -- get high data 
     pata_hd_sector_buffer_lo[count1] = pata_hd_data_low  -- get low data 
     pata_hd_iord = low ^ PATA_HD_NO_INVERTER   -- end read pulse
   end loop

  pata_hd_sector_select = pata_hd_sector_select + 1  
  pata_hd_sector_count = pata_hd_sector_count + 1   
end procedure


Of course changing the data format of pata_hd_sector_buffer requires 
modification of everything that uses it. It is however not used heavily in 
jallib yet. So it would be worth thinking about this change as soon as 
possible, once some libraries rely on the format of pata_hd_sector_buffer, it 
will be harder to change it.

Greets,
Kiste


-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
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.

Reply via email to