Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises

SD Card HAL API bug

Altera_Forum
Honored Contributor II
965 Views

Not sure if someone has posted this before. 

 

There is a bug in the function "alt_up_sd_card_read()

 

When reading the byte from SD card (line 1733), the data is cast to (char) and then returned as (short int). However, if the byte read is 0xFF, it will be sign extended and 0xFFFF will be returned. Unfortunately this is the same as -1, indicating end of file. Thus, there is no way to distinguish between an EOF and reading a 0xFF.  

 

the correction is to cast to (unsigned char) before returning. 

 

For my installation, the file is located here: 

C:\altera\12.0sp2\ip\University_Program\Memory\altera_up_sd_card_avalon_interface\HAL\src\altera_up_sd_card_avalon_interface.c
0 Kudos
0 Replies
Reply