View previous topic :: View next topic |
Author |
Message |
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Jun 16, 2012 3:08 pm Post subject: AVR Dos with a SDHC card in HW SPI mode on a atmega1284p |
|
|
Hi all,
I'm currently trying to get a 8Gb SDHC card working with AVR dos on a atmega1284 in hardware spi mode. The AVR is running at 7.37MHz@3.3Volt (so no level shifters on the SPI bus). When I call the DriveInit() function the AVR appears to hang. The hardware setup looks OK to be (breadboard SPI wires only about 6cm long, powersupply good decoupled).
Anyone got an idea what I can check?
Running Bascom 2.0.7.4.002 the rest of the board is running well, including a software serial output, it's just the sd card that isn't working.
If i use the sd card driver then the init function ends with error 226/227.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Jun 16, 2012 3:50 pm Post subject: |
|
|
Hi,
I'm not trying soft SPI and I'm getting driveinit error 233, so maybe by powersupply might not be as good as I thought. I'll have a look at that.
But I'm still waiting for other possible solutions/what I should check.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Sat Jun 16, 2012 4:01 pm Post subject: |
|
|
...did you unplug the SPI Programer? _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Jun 16, 2012 4:25 pm Post subject: |
|
|
Hi,
No, the programmer is still plugged in, I'll try that.
After seeing this post http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=3910&highlight=error+233 I ran a check on the card on my PC and no change in hw spi mode.
When I run in soft SPI mode I've now got the card to work, it's really slow (it takes several seconds to init the card/read the root dir and display the drive size/free space.)
I'll try shortening the wires on the SPI bus, maybe that might help as it seems to be a speed related problem.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Jun 16, 2012 7:52 pm Post subject: |
|
|
Hi,
OK I've shortend the spi wires abit and the avr still locks up in driveinit with hw spi and with software spi I'm getting error 233.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Sun Jun 17, 2012 9:33 am Post subject: |
|
|
did you try different card's? _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jun 17, 2012 9:58 am Post subject: |
|
|
Hi,
Unfortunatly I don't have a different card. Or better put if I used the only other card I have and kill it my wife would kill me.
I'm currently rebuilding a new board, I've got a feeling that I've got a bad solder joint somewhere. Sometimes I can get the card initalised in soft spi mode and sometimes not (error 233). Hardware SPI never seems to work.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Sun Jun 17, 2012 11:44 am Post subject: |
|
|
try Pullup on MOSI...
i've only a couple of card's working... most didn't work
best is 1GB or at max 2GB Card's or very old 256/512MB. 8 or 16 GB never works for me. _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jun 17, 2012 1:05 pm Post subject: |
|
|
Hi,
OK using soft spi I'm getting:-
Code: | AVR Dos tester
SOFT SPI INTERFACE
INIT CARD
INIT COMPLETED
Load/init lib completed
Card init OK
Card check error 225
Card reset OK
File sys init error code = 0
SD Card type 12
Card size 7761920 kB
Free space 7743776 kB
ALTERN~1.LOG APPORT.LOG AUTH.LOG BOOT.LOG DAEMON.LOG DPKG.LOG FONTCO~1.LOG KERN.
LOG LPR.LOG MAIL.LOG MYTHBU~1.LOG PM-POW~1.LOG PYCENT~1.LOG UFW.LOG USER.LOG XOR
G0~1.LOG Finished |
With this configuration
Code: | Print #3 , "SOFT SPI INTERFACE"
' Chip Select Pin => Pin 1 of MMC/SD
Config Pinb.4 = Output
Mmc_cs Alias Portb.4
Set Mmc_cs
' MOSI - Pin => Pin 2 of MMC/SD
Config Pinb.5 = Output
Set Portb.5
Mmc_portmosi Alias Portb
Bmmc_mosi Alias 5
' MISO - Pin => Pin 7 of MMC/SD
Config Pinb.6 = Input
Mmc_portmiso Alias Pinb
Bmmc_miso Alias 6
Portb.6 = 1 ' pull up
' SCK - Pin => Pin 5 of MMC/SD
Config Pinb.7 = Output
'Set Portb.7
Mmc_portsck Alias Portb
Bmmc_sck Alias 7 |
With hardware configuration I'm seening:-
Code: | AVR Dos tester
SPI HW CONFIG
SPI2X0 0
WCOL0 0
SPIF0 0
SPR00 0
SPR10 0
Cpha0 1
Cpol0 1
Mstr0 1
Dord0 0
Spe0 1
SPIE0 0
SPI INIT OK
INIT CARD |
with this configration
Code: | Config Pinb.4 = Output ' define here Pin for CS of MMC/SD Card
Mmc_cs Alias Portb.4
Set Mmc_cs
' Define here SS Pin of HW-SPI of the CPU (f.e. Pinb.0 on M128)
Config Pinb.4 = Output ' define here Pin of SPI SS
Spi_ss Alias Portb.4
Set Spi_ss ' Set SPI-SS to Output and High for Proper work of
Portb.6 = 1 'pull up on miso
' HW-SPI is configured to highest Speed
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
'Spsr = 1 ' Double speed on ATMega128
Spiinit
Wait 1
Print #3 , "SPI2X0 " ; Spsr.spi2x0
Print #3 , "WCOL0 " ; Spsr.wcol0
Print #3 , "SPIF0 " ; Spsr.spif0
Print #3 , "SPR00 " ; Spcr.spr00
Print #3 , "SPR10 " ; SPCR.Spr10
Print #3 , "Cpha0 " ; SPCR.Cpha0
Print #3 , "Cpol0 " ; SPCR.Cpol0
Print #3 , "Mstr0 " ; SPCR.Mstr0
Print #3 , "Dord0 " ; SPCR.Dord0
Print #3 , "Spe0 " ; SPCR.Spe0
Print #3 , "SPIE0 " ; SPCR.Spie0
Print #3 , "SPI INIT OK" |
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Jun 17, 2012 1:32 pm Post subject: |
|
|
you have access to the SLA right? I would advise to pull the MMCSD_HC.LIB from there.
I did some work on this lib to make it work with all cards. _________________ Mark |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jun 17, 2012 1:53 pm Post subject: |
|
|
Hi,
For information I'm running bascom 2.0.7.4.002 on windows xp
I've downloaded the mmcsd_hc.lib from 17.6.2012 14:30 and when I try and compilemy test program I'm getting:-
Code: | Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd0 = &H40 + 0] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd1 = &H40 + 1] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd8 = &H40 + 8] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd9 = &H40 + 9] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd10 = &H40 + 10] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd16 = &H40 + 16] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd17 = &H40 + 17] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd24 = &H40 + 24] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd55 = &H40 + 55] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_Cmd58 = &H40 + 58] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_ACmd13 = &HC0 + 13] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 215 Line : 91 Unknown ASM mnemonic [..equ _mmcsd_ACmd41 = &HC0 + 41] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD0]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD8]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD9]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD10]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD16]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD17]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD24]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD58]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_ACMD13]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_ACMD41]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_ACMD41]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD1]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_ACMD41]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD0]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD8]] , in File : C:\avr dos test\AVR-Dos-Test.bas
Error : 222 Line : 91 Illegal character [expected (, got '' [_MMCSD_CMD55]] , in File : C:\avr dos test\AVR-Dos-Test.bas |
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Jun 17, 2012 2:11 pm Post subject: |
|
|
i guess you do not have the matching config files. i uploaded them too with a sample. _________________ Mark |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jun 17, 2012 2:48 pm Post subject: |
|
|
Hi and thankyou,
It's working now
I had to modify the config_mmcsd_hc.bas abit to configure the hardware SPI bus and call spiinit for the mega chips. But now it's running in HW SPI mode at 4MHz.
Thankyou very much for your help.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Tue Jun 11, 2019 6:21 pm Post subject: |
|
|
Hello Ian,
I try to run a Sdcard with AVRdos
I was succesfull with Arduino ATMEGA2560
but I want to use also a Display HMI nextion, and I have a lot of pb with the couple Arduino and nextion , I don't want to rewrite all inc file that I did for ATMEGA644 ( I have to change the port com)
I know you are succefull with ATMEGA1284 and SD card and AVRdos
would you please send me the modified Config_MMCSD_HC.bas you did
i use the hard setting for SPI, on the MMCSD_HC.bas the cs is to B.0 I change to ss B.4 but I still have error
Dont let me be crazy please
jp _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|