I inserted this code from the example
Code: Select all
CF_File_Write_Init(); // dummy init
Code: Select all
CF_File_Write_Init(); // dummy init
Which port you use for control port?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 exampleAnd 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?Code: Select all
CF_File_Write_Init(); // dummy init
Code: Select all
void main() {
TRISE = 0;
CF_Init(&PORTB,&PORTD); // initialize ports
do
{
PORTE.F0 = CF_Detect();
}while(1==1);
}
we will check (monday)gambrose wrote:I if you run this code on an 18F452 it runs as expected with E0 lighting up when compact flash is inserted.Code: Select all
void main() { TRISE = 0; CF_Init(&PORTB,&PORTD); // initialize ports do { PORTE.F0 = CF_Detect(); }while(1==1); }
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)
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.gambrose wrote:But when port C is used as control port CF_Detect() returns 1 even if there is no card present.
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"gambrose wrote:but even with no pull down resistors i measured 2V which does not seem to work for port C.