Altera_Forum
Honored Contributor
16 years agoIOWR, IOWR_32DIRECT, alt_flash_read... need help to get the bits
I have got a quite simple problem I think, but I am messing around about half a day now with that and don't figure it out. So I would like to ask for your advice.
I want to copy data from my EPCS Flash to a SDRAM. I can do it with this rather ugly method:
int i;
char read_data;
for(i=0; i<size; i++){
//in
ret_code = alt_read_flash(my_epcs, i<<2, &(read_data), 1);
ret_code = alt_read_flash(my_epcs, (i<<2)+1, &(read_data), 1);
ret_code = alt_read_flash(my_epcs, (i<<2)+2, &(read_data), 1);
ret_code = alt_read_flash(my_epcs, (i<<2)+3, &(read_data), 1);
//out
IOWR_8DIRECT((SDRAM_2_MASK0_BASE+3), ((i-1)*32/8), read_data);
IOWR_8DIRECT((SDRAM_2_MASK0_BASE+2), ((i-1)*32/8), read_data);
IOWR_8DIRECT((SDRAM_2_MASK0_BASE+1), ((i-1)*32/8), read_data);
IOWR_8DIRECT((SDRAM_2_MASK0_BASE) , ((i-1)*32/8), read_data);
}
Can someone give me a working example how to do this with 32bit directly? Everytime I try it with IOWR it get messed up. My C-knowledge isn't so well, so I think I mess up with the pointers and adresses some kind of. Thanks in advance, I really need this urgently.