Hi, i have a question... i can't find the reason for the following behavior.
The pins are too slow when used as input (?)
Please try the sketch below (connect pin 2 to pin 5 first!)
It toggles pin 2, then reads the port.
The first reading is zero. (remarkable: at any F_CPU)
Is that correct ? It looks like a filter somewhere...
For 120MHz, it works, when i insert the two NOPs.
Reason for my question: I'm accessing a flash chip in parallel mode and need a lot of nops between setting clk and reading the port to get valid results. The chip is fast enough, it is the Winbond W25Q128FV, so this should'nt be the problem....
But: For the W25Q128FV, two NOPs are not enough. i need 4... Why ?
It does respond to every sck without nops in between, so think that is a sign that the chip is fast enough i have to inbsert the NOPs for reading the port only...
The first time i struggled about this was a year ago, when in tried the same with a SD-Card. Same issue.
Output:
edit: see below.
Edit:
Even more interesting:
Connect the wire to GND instead.
sry, the output above is from an old version with gnd connection
The pins are too slow when used as input (?)
Please try the sketch below (connect pin 2 to pin 5 first!)
It toggles pin 2, then reads the port.
The first reading is zero. (remarkable: at any F_CPU)
Is that correct ? It looks like a filter somewhere...
For 120MHz, it works, when i insert the two NOPs.
Reason for my question: I'm accessing a flash chip in parallel mode and need a lot of nops between setting clk and reading the port to get valid results. The chip is fast enough, it is the Winbond W25Q128FV, so this should'nt be the problem....
But: For the W25Q128FV, two NOPs are not enough. i need 4... Why ?
It does respond to every sck without nops in between, so think that is a sign that the chip is fast enough i have to inbsert the NOPs for reading the port only...
The first time i struggled about this was a year ago, when in tried the same with a SD-Card. Same issue.
Code:
void setup() {
pinMode(13, OUTPUT); //LED
pinMode(2, OUTPUT);
pinMode(5, INPUT);
CORE_PIN2_CONFIG = 0x140; // DSE enable, Fast Slew Rate
CORE_PIN5_CONFIG = 0x100; // passive filter off
}
void loop() {
// put your main code here, to run repeatedly:
uint8_t b[8];
GPIOD_PCOR = 1; // pin 2 = low
memset(b, 0, sizeof(b)) ;
delay(1);
GPIOD_PTOR = 1; //toggle pin 2
/*
asm volatile("nop");
asm volatile("nop");
*/
b[0] = GPIOD_PDIR; // this reads what ?
b[1] = GPIOD_PDIR;
b[2] = GPIOD_PDIR;
b[3] = GPIOD_PDIR;
b[4] = GPIOD_PDIR;
b[5] = GPIOD_PDIR;
b[6] = GPIOD_PDIR;
b[7] = GPIOD_PDIR;
for (int i = 0; i < sizeof(b); i++)
Serial.printf("%d ", b[i]);
Serial.println();
GPIOC_PTOR = (1<<5); ///blink...
delay(200);
}
Output:
edit: see below.
Edit:
Even more interesting:
Connect the wire to GND instead.
sry, the output above is from an old version with gnd connection
Last edited: