const byte InterruptPin = 1;
void setup(){
pinMode(InterruptPin, INPUT);
attachInterrupt(digitalPinToInterrupt(InterruptPin), CPI_Time, RISING);
}
void CPI_Time(){
int clk_1 = ARM_DWT_CYCCNT;
asm(
"nop \n\t"
"nop \n\t"
"nop \n\t"
"nop \n\t"
"nop"
);
int clk_2 = ARM_DWT_CYCCNT;
Serial.printf("CPI: %d \n", clk_2-clk_1);
}
CPI: 3
CPI: 3
CPI: 3
CPI: 3
CPI: 3
...
I know I will need to use IOMUX somehow, to tell port 6 to be GPIO, and I want to use pins:
17, 16, 22, 23, 20, 21, 26, 27
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(20, INPUT);
pinMode(21, INPUT);
pinMode(22, INPUT);
pinMode(23, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
I want to use pins:
17, 16, 22, 23, 20, 21, 26, 27 in that order to get the 8 bits out of GPIO6 since the bits are all pretty close to each other and can be addressed using 0xCFC00000 --> 0B11001111110000000000000000000000
uint32_t sample = GPIO6_PSR;
// shift bits 22-27 to bits 0-5
buffer[i] = (sample & 0x0FC00000) >> 22;
// shift bits 30-31 to bits 6-7
buffer[i] = buffer[i] | (sample & 0xC0000000) >> 24;