|
|
View previous topic :: View next topic |
Author |
Message |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
still no joy |
Posted: Sun Jun 16, 2013 8:07 pm |
|
|
Ok, my circuit is now 3.3V,
SDI, O and SS are pulled up tested with 1K, 4.7K (both the same result)
and its the same.
all I'm trying to do is play back a 22Khz wave file ;) it works i've heard it, but i need stability on ALL cards
I've even tried using Timer2 as the Clock timing circuit |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Made some changes |
Posted: Mon Jun 17, 2013 1:16 am |
|
|
neochrome32 wrote: | OK, everything is now running on 3.3V. the circuit diagram is changed
...
removed the resistors and pulled the lines up.
from what i've read and learned today, this is how is should be... | In your schematic the pull-up on SDO from the SD card is missing. This is the most important pull-up as the SD card starts operating in Open-Collector mode.
Quote: | SDI, O and SS are pulled up tested with 1K, 4.7K (both the same result) | You are still in the second group of users!
Please try and get the SD card specification and do some reading! The pull-ups are specified for the 10k to 100k range.
The wrong value for the pull-ups isn't your problem, just makes the bus slower and wastes power. What does worry me is your attitude of just throwing some components together and then telling us that it isn't working. This doesn't motivate me to help you. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19326
|
|
Posted: Mon Jun 17, 2013 2:17 am |
|
|
OK.
So now we move forward.
Again use two #use spi commands, with different stream names.
Key though is that the initialisation code will use software SPI. Reason is that the hardware, cannot actually go slow enough, without being programmed differently.....
Code: |
//In your configuration
#use spi(MASTER,FORCE_SW,baud=100000, DO=PIN_C5,DI=PIN_C4,CLK=PIN_C3,STREAM=SLOW,MODE=0);
#use spi(MASTER,SPI1,STREAM=FAST,MODE=0,baud=16000000);
#bit SSPEN=getenv("BIT:SSPEN")
//Nothing else is needed to initialise thee SPI. Get rid of all the other
//functions/defines you have.
//Then in the code
//Now send your init commands using the 'SLOW' stream
SSPEN=FALSE; //turn off the hardware port
returned_val=spi_xfer(SLOW,init_data,bits=8); //etc....
//Now this can talk to the pins without the hardware interfering
//Then when you want to go 'fast', use:
SSPEN=TRUE;
returned_val=spi_xfer(FAST,what_you_want_to_send,bits=8); //etc.
|
Once you have gone 'fast', you never need touch anything, just using the spi_xfer to the fast stream, and the data will be sent at the fast rate.
Neatly, the TRIS settings for hardware and software are the same, so simply turning the port 'on', ant talking to the hardware port, is enough to switch modes.
Remember you need to turn off the analog functions on these pins.
Don't think 'smaller is better' with the pullups. You have gone below the legal values. The _required_ values are 10K to 100K on the data lines, and 10K to 90K on the CS line. MMC allows the latter to go down to 5K, and limits the former to 50K max. hence the 'standard' is to either use 10K on all the lines, or use 10K on the CS line, and 50K on the others, which is 'in spec' for both interfaces.
They have two separate functions. The one on DI, ensures the line does not float, even when no card is present. This also applies to the one on CS, for the short moment when the PIC boots, if it takes longer to wake than the card. They also serve to fractionally improve the speed of the rising edges of the signals, which becomes important when you start trying to clock faster. |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
GRRRRRRR |
Posted: Mon Jun 17, 2013 8:40 am |
|
|
OK, back to the drawing board - 4.7K? was meant to be 47, but im gunna go 10K, will look at the electronic values before decide..
in the diagram though, from SDO (PIC) ---- SDI (CARD) this is to show that the pin from CHIP to CARD,
i got info about changing the SSP1ADD = 2 this changes the BAUD rate on the SPI clock. no need for TWO #USE SPIs its messy and it didn't work so well when i tried it (again hardware is problem here...)
--- THANKS for the feed back ----
Hardware according to the SD Specs, say 10-90K
im using 10k, as my electronics is running around 3.1 (stable)
should pull the pins sharply up. the PIC adcs are OFF (set in software using Code: |
setup_adc(ADC_OFF);
setup_adc_ports (NO_ANALOGS);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
|
i pulled pins up, SDO, SDI, CS
the specs say not to bother with the clock?? (so i am leaving that open) the set_tris_c should point to SDO = output, SDI = 1, CS=0 and CLK=0
im using SPI mode so according to the specs i have this circuit ready.
10ks used |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19326
|
|
Posted: Mon Jun 17, 2013 11:07 am |
|
|
OK. So you have changed to using a faster rate for the initialisation. I was sticking with your original desire to support 10240bps. This is only available using software. The slowest you can get with the hardware is 62500bps. Legally 100K is fine for the initialisation. Technically the legal range is 100K to 400K, so the 10240 you were using was slower than legal.
I actually think using two streams is clearer. It means you inherently document every write to say what speed is used. Personal though. Remember the use spi lines only go into the initialisation, they don't have to appear in the code as such.
However, why '2'?.
The fastest you can take the SPI, uses zero in SSPADD, to give 16MHz. Two takes you down to only 5.3MHz.
Best Wishes |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Mon Jun 17, 2013 12:04 pm |
|
|
The ultimate goal is to initialize at 100K
then use full speed.
Though to be honest, SSP1ADD=2 was all the card would cope with :(
I believe my hardware still has problems, despite looking at the specs on the sdcard.
Changing SSP1ADD will serve altering the BAUD rate, without having multiple USE SPI's (avoid if possible).
it initializes ok on ALL cards
SSP1ADD=13
all the while using HW SPI
OH I miss calculated the baud! 10240 i thought was 102khz! 10khz is a tad too small isn't it lol!!
sorry should have made that clear :( want to have slow startup. then fast as possible..
im starting to think (if my hardware is correct) that some cards cant go any faster thatn 400Hhz (lol) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19326
|
|
Posted: Mon Jun 17, 2013 2:57 pm |
|
|
A lot depends on your PCB layout.
Once you get into the MHz range, you are dealing with transmission lines.
A small series resistor, in the signal lines where they go into the PIC may help. Reduces the reflection at the end of the line. Perhaps 47R to 200R.
You certainly should be able to go to 16Mhz, if the lines are reasonably laid out.
Best Wishes |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
circuit layout. |
Posted: Mon Jun 17, 2013 4:54 pm |
|
|
its a basic getup.
i got it doing the higher speed, but only one of the sdcards seems to accept it, so again my hardware STILL maynot be configured..
am i right that changing the SSP1ADD is the way to go for altering the HW SPI baud?
is there a command i should be doing to the SDCARD to say "init finished - go high speed"?
since the SD specs didn't mention it
-------EDIT ------
OK, after doing a loop, for(;;) spi_xfer(0x55);
and it produced a frequencey on the clock 2.6Mhz, it was far too quick for the SDcard i think, though , i thought SDcard v1.0 has a speed of 25MBytes??
- looks like i need to look into HC-SD. the instructiosn aren't work though.. this is for another topic..
--- thanks everyone ---- |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19326
|
|
Posted: Tue Jun 18, 2013 1:14 am |
|
|
You are using the SPI interface, not the nibble wide interface. Speed on this is allowed to go to 25Mbps. (mega _bits_ per second), on all 'full speed' cards.
To move data faster requires reprogramming the card to use the nibble wide interface and transfer a nibble at a time.
However the card interface may support 25Mbps, but the fastest you can clock SPI with a PIC at 64MHz, is 16Mbps. 2MBps.
You are never going to get even remotely 'close' to this with a PIC16/PIC18. You need to be using things like the DsPIC, with DMA, to actually move data at these sort of rates, for more than a very few cycles (if you remember it takes something like ten instructions just to access a byte in an array - so just over 1MBps, at best).
The only cards that won't support going to 25MHz, are MMC, rather than SD.
Best Wishes |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Tue Jun 18, 2013 11:39 am |
|
|
Yeah i know but when i SSP1ADD = 1, the Cards just don't work. except 2 of them, the others just break...
otherwise SSP1ADD = 13. ALL work fine...
also, yeah 64Mhz / 4 (pll)
dsPIC is something i wanna go, but i just wanted to get the basics of SDCards working.. again though, I'm not getting 2MBytes using the loop anyways... reprogramming sure, but 16Mips.. I'm thinking 40mips to do something better..
just looks like limitations from my coding and PIC ;)
-- thanks again.. you've are extremely helpful ---
-- EDit ---
even at my chip speed, the full speed SSP1ADD = 0x00 should send the output clock in a massive frenzy of clocks... the card just isn't working beyond 2Mhz (spi_clock)
from the specification and you advise, using 100R limiting and / or SDO pulled high 33K, SDI pulled high 33K, CLK Pulled HIGH (tried low) the CS pulled high
still cant make it go faster!
the chip is running pefect 3.3V, and same on the card too...
in the specs.pdf doesnt mention anything about difference speeds, 25Mhz is of all basic SDcards.. just not getting anywhere close to that, even 16MHZ (theoretical) about 2Mhz and even the the data stream is ropey!
(even went mad and removed ALL resistors, 3.3V on a sacrificial card)
no dice, the card still works :D |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|