|
|
View previous topic :: View next topic |
Author |
Message |
ranga_ccs
Joined: 11 Aug 2011 Posts: 3
|
mk_file was not working (very urgent, please respond mail) |
Posted: Sat Aug 13, 2011 9:42 am |
|
|
Hi all,
I'm working on pic18f67j10 microcontroller, ccs compiler version is 4.121.
I'm working on memory module for storing log data but when I'm calling mk-file, it was continuously in while loop in get_next_free_entry function.
Code: |
mk_file->set_file_name->get_next_free_entry
signed int get_next_free_entry(int32* start_addr)
{
int buf;
int32 i;
i = *start_addr;
if(mmcsd_read_data(i, 1, &buf) != GOODEC)
return EOF;
while(buf != 0)
{
i += 0x1F;
// get the next address
if(get_next_addr(&i) == EOF)
if(alloc_clusters(addr_to_cluster(i), &i) == EOF)
return EOF;
if(mmcsd_read_data(i, 1, &buf) != GOODEC)
return EOF;
}
*start_addr = i;
return GOODEC;
}
|
Thanks |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Aug 13, 2011 9:44 pm |
|
|
If you're using the MMC/SD library bundled with the CCS compiler, there is a bug in the get_next_addr function that might be your problem. See my thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=43417
BTW, it doesn't matter how urgent you think your problem is, no one is going to email you. _________________ Andrew |
|
|
ranga_ccs
Joined: 11 Aug 2011 Posts: 3
|
|
Posted: Fri Aug 19, 2011 1:40 am |
|
|
Thanks andrewg for your response.
I checked the link you have forwarded but I'm using updated fat and mmcsd drivers only. Still the problem was not resolved.
Can I know, what are the initial initialization steps we need to follow for mmcsd and fat system when we are using PIC18F67J10, oscillator=8M, clock=32M ?
The following initialization steps I had done in my code.
Code: |
#include <18F67J10.h>
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz forPCD)
#FUSES DEBUG //Debug mode for use with ICD
#FUSES NOXINST //Extended set extension and Indexed
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#use delay(oscillator=8M,clock=32M)
//UART CONFIGURATIONS
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=U1)
#use rs232(baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=U2)
/******************************SD CARD ******************************/
#ifndef MMCSD_PIN_SCL
#define MMCSD_PIN_SCL PIN_D6 //o
#define MMCSD_PIN_SDI PIN_D5 //i
#define MMCSD_PIN_SDO PIN_D4 //o
#define MMCSD_PIN_SELECT PIN_D7 //o
#endif
#use spi(SPI2, MODE=0, BAUD=3000000, DI=MMCSD_PIN_SDI, DO=MMCSD_PIN_SDO, CLK=MMCSD_PIN_SCL, BITS=8, MSB_FIRST, IDLE=1, SAMPLE_RISE, stream=mmcsd_spi)
|
Can I know if anyone faced like this problem, please give us some direction.
Thanks |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sun Aug 21, 2011 6:23 am |
|
|
Your #use spi line is completely wrong. Get rid of it. Just #include mmcsd.c after the MMCSD pin definitions and see how that goes. _________________ Andrew |
|
|
ranga_ccs
Joined: 11 Aug 2011 Posts: 3
|
File was not creating in SD card . |
Posted: Thu Aug 25, 2011 9:42 am |
|
|
Hi Andrewg,
I removed #use spi and I already included mmcsd.h file but the problem was not resolved.
I’m not able to create file and directories in my MMCSD memory card by using fat and mmcsd drivers of CCS compiler. I'm calling mk_file function(fat driver function) in config_file_open()function in my source code(memory_fat.c). mk_file was returning 0xFF value but it has to return 0x00 if it was successfully completed.
With my understanding mk_file was getting 0xff value from mk_file ->set_file_name ->make_short_file_name function.
Sometimes it was continuously waiting in the mk_file ->set_file_name -> get_next_free_entry function.
I copied my main part of source code and header file:
source code:
Code: |
int config_file_open()
{
int i,k=0;
int k1=0;
int config_init=99;
int config_mkfile=2;
int config_openfile=90;
int config_readfile=77;
char wcmd[2] = "r";
for(i=0;i<50;i++)
{
temp_buff[i]='\0';
}
k=0;
while((config_init != 0)&&(k<3))
{
config_init = fat_init(); //init the fat32 file system
k++;
}
if(config_init != 0)
return 0; //On fail return 0
strcpy(temp_buff,"/config.txt");
k=0;
while((config_mkfile != 0)&&(k<3))
{
config_mkfile = mk_file(temp_buff); //Create empty file
k++;
}
}
|
Header file:
Code: |
#include <18F67J10.h>
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES DEBUG //Debug mode for use with ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
//#use delay(clock=8000000)
#use delay(oscillator=8Mhz,clock=32Mhz)
//UART CONFIGURATIONS
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=U1)
#use rs232(baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=U2)
/******************************SD CARD ******************************/
#ifndef MMCSD_PIN_SCL
#define MMCSD_PIN_SCL PIN_D6 //o
#define MMCSD_PIN_SDI PIN_D5 //i
#define MMCSD_PIN_SDO PIN_D4 //o
#define MMCSD_PIN_SELECT PIN_D7 //o
#endif
|
Please give us some direction on this.
Thanks |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Thu Aug 25, 2011 10:28 pm |
|
|
Run chkdsk on the card to make sure there's no obvious detectable errors on it. Apart from that, you're going to have to trace through the code to the point where it's getting stuck.
It's possible there's a bug in the drivers. I've not used the drivers for writing (yet).
If you don't want to debug the CCS drivers, then you'll have to try some other drivers. Lots of people here (but not me) have used the drivers from Brush Electronics ( http://www.brushelectronics.com/ ).
One day I'll get around to trying out the writing code, but not for a while. _________________ Andrew |
|
|
|
|
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
|