Reading from SD Card

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Reading from SD Card

Post 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.
SD card retrieve trial.fcf_pic16
(15 KiB) Downloaded 318 times
Could anyone please help me figure this out?

Thanks in advance.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading from SD Card

Post 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.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: Reading from SD Card

Post 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??

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading from SD Card

Post 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.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: Reading from SD Card

Post 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.
Untitled.png
(26.25 KiB) Downloaded 2283 times
The prescalar seems to be affecting the program. Where could my mistake be?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading from SD Card

Post 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)

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: Reading from SD Card

Post 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.

Post Reply