Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

SD Card HAL API bug

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
No RepliesBe the first to reply