CF_Detect()

General discussion on mikroC.
Post Reply
Author
Message
gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

CF_Detect()

#1 Post by gambrose » 13 May 2005 17:42

I don’t seem to be getting the desired effect from the CF_Detect() it dose not seem to detect that no CF card is inserted.

I inserted this code from the example

Code: Select all

CF_File_Write_Init();        // dummy init
And it fixed it I see that it is commented as dummy is this to workaround the CF_Detect not working or am I not doing something right?
Graham Ambrose

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: CF_Detect()

#2 Post by rajkovic » 13 May 2005 21:41

gambrose wrote:I don’t seem to be getting the desired effect from the CF_Detect() it dose not seem to detect that no CF card is inserted.

I inserted this code from the example

Code: Select all

CF_File_Write_Init();        // dummy init
And it fixed it I see that it is commented as dummy is this to workaround the CF_Detect not working or am I not doing something right?
Which port you use for control port?

We never had problem with CF_Detect().

But when we used portc as control for some strange reasone it need dummy init to get write and read to work.
PORTB work allways.

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#3 Post by gambrose » 14 May 2005 08:35

I was using PORTC i will have to have another play using port B
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#4 Post by gambrose » 14 May 2005 16:07

Code: Select all

void main() {
   TRISE = 0;
   CF_Init(&PORTB,&PORTD);                 // initialize ports
   do
   {
       PORTE.F0 = CF_Detect();
   }while(1==1);
}
I if you run this code on an 18F452 it runs as expected with E0 lighting up when compact flash is inserted.
But when port C is used as control port CF_Detect() returns 1 even if there is no card present.

(You can get the same behaviour on PORTB with out the flash board plugged in)
Graham Ambrose

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

#5 Post by rajkovic » 14 May 2005 21:00

gambrose wrote:

Code: Select all

void main() {
   TRISE = 0;
   CF_Init(&PORTB,&PORTD);                 // initialize ports
   do
   {
       PORTE.F0 = CF_Detect();
   }while(1==1);
}
I if you run this code on an 18F452 it runs as expected with E0 lighting up when compact flash is inserted.
But when port C is used as control port CF_Detect() returns 1 even if there is no card present.

(You can get the same behaviour on PORTB with out the flash board plugged in)
we will check (monday)

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

#6 Post by pizon » 16 May 2005 16:13

gambrose wrote:But when port C is used as control port CF_Detect() returns 1 even if there is no card present.
The trick is, that PORTC has Schmitt-trigger buffers on it, whilst PORTB is TTL port. This means that PORTC has a wider 'gray-state' input DC voltage gap than PORTB. Now, if you take a look at the CFlash connection scheme in mikroC Help, you'll see that the CF_DETECT pin (Ctrlport.F4) has a 10K pull-up resistor, meaning that the abovementioned pin will have ~2.5V on it when no CF card is present, if you use external pull-down on Ctrl port. For PORTC this is a 'grey-state' area. For PORTB, however, this is logical high.

So, in short terms, PORTC MUST NOT BE PULLED DOWN WHEN USED AS CONTROL PORT for Compact Flash. The best thing to do is disconnect the pulling resistors from PORTC. The data port, being a 'pure' I/O, is unaffected by pull-up/pull-down arrangements.
pizon

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#7 Post by gambrose » 16 May 2005 17:29

that's a good explanation I'm not sure i understand it totally as i am unfamiliar with the workings of Schmitt-triggers.

but even with no pull down resistors i measured 2V which does not seem to work for port C.

could this be cured by using an alternative resistor? I am not an electronics genius I'm afraid.
Graham Ambrose

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

#8 Post by pizon » 16 May 2005 18:17

gambrose wrote:but even with no pull down resistors i measured 2V which does not seem to work for port C.
:?: With no pull-downs it should measure Vdd, i.e. ~5V. 2V is not enough to achieve a logical '1' on Schmitt's. Acc. to the P18F452 datasheet, it accepts voltages >=3.5V to be logical '1', and <=1.5V to be logical '0', on pin RC4 (ctrl_port.CF_DETECT). You seem to have something else that is "pulling your voltage down" :?:
pizon

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#9 Post by gambrose » 16 May 2005 18:29

worked out what was pulling the voltage down it was the the port LEDs on my easyPIC board.

works fine now thanks for the explanation.
Graham Ambrose

Post Reply

Return to “mikroC General”