Hi all,
I have an application which uses an external SRAM card as memory extension. It is based on the schematic from TL - see this post: http://www.midibox.org/forum/index.php?topic=4140.msg27685#msg27685. For the CARD PRESENT status of the card (= is it connected to the core or is the card disconnected) I am currently using one DIN pin. The detection mechanism is very simple: there is one pin on the card connector that is connected to ground by the card whenever it is inserted, and which is connected to +5V via a pullup resistor whenever no card is inserted.
This works well and gives me the correct status whenever the status changes, that means whenever I connect or disconnect the memory card. BUT the problem is that I am not interested in the change of the status, but in the status itself: upon powering up the core, I have no means of detecting whether the card is connected or not, because the DIN mechanism is checking for transitions.
Now, I am trying to use pin A7 of J5 (that is RE2 of the core 18F452) in the same manner: I have a pullup of 100k against +5V, and whenever the card is inserted, the pin is drawn to ground. To my knowledge, the C code necessary to initialize the input of Port E is very simple:
/////////////////////////////////////////////////////////////////////////////
// This function is called after startup to initialize the SRAM
/////////////////////////////////////////////////////////////////////////////
void SRAM_Init(void) __wparam
{
// disable the ADC which allocates the analog pins
// only needed if controls pins are connected to port A
ADCON1 = 0x07;
...
// configure RE2 as input for reading SRAM card status
// Pin RE.2 = input
TRISEbits.TRISE2 = 1;
return;
}
Then I only have to check the status of that pin regularly, e.g. in [tt]Tick(void)[/tt], using something like:
app_flags_t.SRAM_CARD_STATUS = PORTEbits.RE2;
which could be defined the same way as the DISPLAY_UPDATE_REQ flag in the sdcc_skeleton demo code.
So why did I put this into “Troubleshooting” and not “Programming in C”? Well, it does not work this way, and I tried to meter the potential of the RE2 pin using a multimeter. In fact, that pin is always at ground level, no matter if the card is connecting the pin to ground or not! So… is the pullup resistor too large (100 kOhm)?
I also measured the resistance accross the resistor (with the circuit powered off, of course). It reads about only 20 kOhm when the “circuit” is connected to pin RE2. If I disonnect it from there (pulling the J5 plug), then the resistor value reads 100 kOhm as it should be. If I connect the card, then the resistance across the pullup drops further down to about 2 kOhm. J5 disconnected and card inserted gives me 28 kOhm across the 100 kOhm pullup. I am sure there is no short circuit, that is why I really don’t get any further here. Any suggestions? Do I need to do something more to the core / the PORTE input? Do I need to change the pullup’s resistor value to get to a decent potential at pin RE2?
??? ??? ???
Best regards, ilmenator
