AK-SDFS-UART doesn't work

Hello
I bought this module and it doesn’t work!!!

  1. I use an Atmega1284 (UART0, 9600 Baud) to control the module
  2. When I insert an SD card, the DISK LED does not light up
  3. I don’t get feedback from the module when I send a command, but the PROT LED lights up for a short time
  4. I use CRC16-CCITT as a checksum, okay?
    Can the module be defective?
    Or what am I doing wrong?!
    Pic01|690x366

'±-----------------------------------------------------
'| Titel : SDCard_UART.luna
'±-----------------------------------------------------
'| Funktion : Test-Programm AK-SDFS-UART
'| SD-Karte mit RS232
'| Schaltung : SG4CTRL
'±-----------------------------------------------------
'| Prozessor : ATmega1284
'| Takt : 20MHz
'| Sprache : LunaAVR 2018r2
'| Erstellt am : 02.08.2019
'| Änderung am : 03.08.2019
'| Version : 1.0
'| Autor : Wolfgang Zindler, Haan
'±-----------------------------------------------------
avr.Device = atmega1284p
avr.Clock = 20000000
avr.Stack = 128
'-------------------------------------------------------
’ Library
'-------------------------------------------------------
#library “Library/CRC16.interface”
'-------------------------------------------------------
’ I/O-Konfigurationen
'-------------------------------------------------------
Uart.Interface = Uart1 'SD-Card
Uart1.Baud = 9600
Uart1.Recv.Enable
Uart1.Send.Enable
'-------------------------------------------------------
’ Variable
'-------------------------------------------------------
Dim SD_Dat(10) As Byte
Dim CRC As Word
'-------------------------------------------------------
’ Main-Programm
'-------------------------------------------------------
SD_Dat(1) = &H41 '“A”
SD_Dat(2) = &H4B '“K”
SD_Dat(3) = &H0C 'FATInfo
SD_Dat(4) = 0
SD_Dat(5) = 0
SD_Dat(6) = 0

CRC16.Start
For i = 1 To 6
CRC16.AddByte SD_Dat(i)
Next
CRC = CRC16.Value

For i = 1 To 6
SD_Print SD_Dat(i)
Next
SD_Print CRC

Halt()

Hello @Wolfzi99,

  1. OK. 9600 is the default baudrate.
  2. The DISK LED turns on when there is at least 1 file opened. So it’s normal if it doesn’t light up yet.
  3. The PROT LED blinks when the board receives/sends serial data. So we can say that the board is alive and at least receiving characters.
  4. Should be OK.

I cannot see the picture you posted. Can you try to post it again?

Unfortunately no one here knows the LunaAVR language. If you have an spare Arduino somewhere, we have code you can try to test if your connections are OK.

Would it be possible to post a hex dump of the entire data you are sending (command FAT info) to see if it matches what we see here when such command is sent?

Do you have an oscilloscope to check if the board is answering (and what is answering)?

The modules are tested here before shipping, so it doubt we have sent a faulty one.

Thanks.
Ivan.

Hello Ivan,

it works now and I get response from the modul with all data.
Thanks for your support.
But I have small problems with the CRC16 calculation!
Can you tell me what kind of CRC16 calculation that is?
I see the example in the manual, but I cannot C.

Regards
Wolfgang

Hi @Wolfzi99

Great. I am glad it is working now.

I digged further and seems that the CRC16 is a custom algorithm. Can you translate the function to your language?

Hi Ivan,
yes me too.
But the CRC checksum is my problem.
I am currently using an online calculator, but this cannot be the long-term solution.
I need a program in Basic or VisualBasic to transfer to LunaAVR.
LunaAVR is similar to Basic!

Regards
Wolfgang

Hi @Wolfzi99,

Unfortunately we don’t have the code in those languages.

By the way, which online calculator are you using?

Hi Ivan,
okay, I’ll find a solution!
What I use is: https://www.lammertbies.nl/comm/info/crc-calculation.html
and than this: CRC-CCITT (XModem)

I have another issue:
Command FAT information
I get these bytes back: 00 A0 E7 00 20 9F E7 00
and I use a 16GB micro SD Card.
How can I determine the capacity of the card from the byte values?

Regards
Wolfgang

Hi Ivan,
Problem solved, the SD card was too big, with 2GB it works.

Next issue: Open File Command
I get no response from the card.

Here is my command code: A K 1 1 0 10 \TD01.txt 0 DA 0B

What is wrong?

Regard
Wolfgang

Hi @Wolfzi99,

It should work with a 16GB SD without any problems.

I see the data is correct but all the bytes are in inverse order:

20 9F E7 00 = 0xE79F20 = ‭15179552‬ KB (free)
00 A0 E7 00 = 0xE7A000 = 15179776 KB (total)

Assuming the CRC is correct, I don’t see anything wrong. What is the answer the board is giving you back?

Maybe the “10”, that should be 0x0A. That is the length of “\TD01.txt” plus the null-termination character.

Hi Ivan,
I get nothing back from the board!

Hi Ivan,

yes I know, in my code I have 0x0A (Dez = 10).

Hi @Wolfzi99,

Try sending the following:

41 4b 01 01 0a 00 5c 54 44 30 31 2e 74 78 74 00 af 48

This should open “\TD01.txt”

Hi Ivan,
Hurrah, it works now and the blue LED lights up!
Error investigation:

  1. The number of bytes (0x0A) is in the wrong place in the manual.
  2. My CRC16 calculator cannot process this amount of bytes.
  3. This CRC16 calculator is better: https://crccalc.com/

Thank you very much for your help.

Wolfgang :yum:

Maybe it seems in the wrong place because it’s a 16 bit value that transmission depends on the endianess of the MCU you are using.

Hello Ivan,
okay, I understood.
Summary:
The following commands I have now tested and they work

  • Check for SD
  • Fat information
  • List directory
  • Open file
  • Close file
  • Read
  • Read Line
  • Close all
    I don’t need more commands for my project at the moment.
    Thank you for your support.

Best Regards
Wolfgang

1 Like