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.
Reading from SD Card
Moderator: Benj
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
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
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??
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??
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
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
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?
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?
- 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
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)
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)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
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
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.
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.