Page 1 of 1
Reading from SD Card
Posted: Wed Apr 04, 2012 8:05 am
by tanjilul
Hello,
I am trying to read a csv file from an sd card using the dsPIC30F4013. However, the program is not reading the entire file but rather a small part of it.
I used a modified version of the example program from the flowcode examples provided online.
Could anyone please help me figure this out?
Thanks in advance.
Re: Reading from SD Card
Posted: Wed Apr 04, 2012 5:03 pm
by Benj
Hello,
How big is the file and how much of the file is the program managing to go through. Eg the number of LCD screen refreshes until it fails.
Hopefully this info should help us to pinpoint where the problem lies.
Re: Reading from SD Card
Posted: Wed Apr 04, 2012 7:28 pm
by tanjilul
Hi Benj,
This morning i got the same code to read through the entire file and display it on the LCD by disabling the watchdog timer. However It does not send the data over the serial line for some reason.
I am trying to use "RS232 Send Char" and reading it on the PC end. Any ideas??
Re: Reading from SD Card
Posted: Thu Apr 05, 2012 11:10 am
by Benj
Hello,
Hm I can't see any reasons why this would be failing unless your clock speed or config settings are incorrect in Flowcode for your hardware and therefore the RS232 baud is being calculated incorrectly. Can you do the basic one second flasher test on the hardware to check all your settings are correct. You can just add a while 1 loop to the start of your program to do this and then delete it again once you have checked your settings are ok.
Re: Reading from SD Card
Posted: Mon Apr 16, 2012 11:30 am
by tanjilul
Hi Benj,
The LED test works fine at the follwoing settings:
Xtal = 12Mhz
PLL Settings = HS2, 16x
Baud Rate at 9600, error 0%
Question is, is my clock frequency 24MHz or 96MHz. The formula below says 24MHz, but the 1 second flasher AS WELL AS RS232 communication only works with 96MHz.
The prescalar seems to be affecting the program. Where could my mistake be?
Re: Reading from SD Card
Posted: Mon Apr 16, 2012 3:42 pm
by Benj
Hello,
Yes 96MHz for your clock speed in Flowcode project options is correct.
(12MHz crystal / 2) * 16 = 96MHz.
The actual instruction rate is 96MHz / 4 = 24MHz which is probably where the confusion is coming in.
Flowcode already knows the specific divider for your device so you do not have to work the instruction rate out for it.
Here is a Baud Calculation
(((CLK_SPEED / BAUD) - 16) / 16)
For you this would be as follows assuming you want a baud of 9600.
(((96000000 / 9600) - 16) / 16)
Re: Reading from SD Card
Posted: Wed Apr 18, 2012 8:48 pm
by tanjilul
Thanks Benj,
But this us back to the original problem where data from the data from the card does not get entirely sent over the serial port.
The macro displays the entire file on the lcd but when i change the code to send to rs232 rather than display lcd, it sends "EOF" suddenly and stops.