when i use connector sd card integrated to easyavr5 the code follow work but when i use connector sd card external connected to PORTB it don't work
SW7 and SW8 are off because i use directly PORTB connected to sd card external.
PORTB.4 = CS
PORTB.5 = MOSI
PORTB.6 = MISO
PORTB.7 = SS (SCK)
Code: Select all
program sd1
dim filename as string[14]
dim filetmp as string[512]
dim ret as byte
sub procedure createFile
dim i as word
Mmc_Fat_Assign(filename, 0x80) ' Will not find file and then create file
Mmc_Fat_Rewrite ' To clear file and start with new data
for i = 0 to 1023
filetmp[i] = "A"
next i
Mmc_Fat_Write(filetmp, 1024) ' write data to the assigned file
end sub
main:
DDRB = DDRB and $A0
DDRB = DDRB or $BF
Glcd_Init(PORTD, 2, 3, 4, 5, 7, 6, PORTC)
Glcd_Set_Font(font5x7,5,8,32)
Glcd_Fill($00)
filename = "IMAGE001TXT"
ret = Mmc_FAT_Init(PORTB,4)
if ret = 0 then
Glcd_Write_Text("Initialization OK",6,1,1)
else
Glcd_Write_Text("InitError",6,1,1)
end if
Glcd_Write_Text("Writing file",6,2,1)
createFile
Glcd_Write_Text("Write ok",6,3,1)
end.
the connector external is a pcb from a dvd player but is ok because is ok from bascom avr connected to portb.
any idea ?