This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Time delay between GPIO clear and set

Hello community,

I'm wondering about a timing issue on my Concerto F28M35 , when i clear the gpio bit 26 and write data to the gpio23-16 register i have time gap of nearly 350 ns (without optimization), the time after clearing the data and setting the gpio bit 26 to hight is just 150 ns.

The yellow signal in the picture is gpio26 and the blue and green is the data, x-axis is in µs.

Here is my code:

	setPinsWritable();

	for (loop_counter = 0; loop_counter < array_size; loop_counter++) {
		GpioDataRegs.GPACLEAR.all = (((unsigned long int) (0x04) << 24)
				& GET_FOURTH_BYTE);           //set low aktiv GPIO 26 write bit
		GpioDataRegs.GPASET.all = (((unsigned long int) (data[loop_counter]) << 16)
				& GET_THIRD_BYTE); 				// write to GPIO23-GPIO16
		asm("nop");//wait one tick bevor rewrite the register
		GpioDataRegs.GPACLEAR.all = (((unsigned long int) (data[loop_counter]) << 16)
				& GET_THIRD_BYTE);			//clear GPIO23-GPIO16
		GpioDataRegs.GPASET.all = (((unsigned long int) (0x04) << 24)
				& GET_FOURTH_BYTE);          //clear low aktiv GPIO 26 write bit

	}



and here my configuration of the gpio pins:
void configRead_WritePin(void) {

	// GPIO24 & GPIO26 are outputs,
	EALLOW;
	GpioCtrlRegs.GPADIR.all = (((unsigned long int) (0x01) << 24)
			& GET_FOURTH_BYTE);;         // Output read bit
	GpioDataRegs.GPASET.all = (((unsigned long int) (0x01) << 24)
			& GET_FOURTH_BYTE);         // set bit as default

	GpioCtrlRegs.GPADIR.all = (((unsigned long int) (0x04) << 24)
			& GET_FOURTH_BYTE);         // Output write bit
	GpioDataRegs.GPASET.all = (((unsigned long int) (0x04) << 24)
			& GET_FOURTH_BYTE);        // clear bit as default

	EDIS;

}
void setPinsWritable(void) {
	EALLOW;
	// set all GPIO D to output
	GpioCtrlRegs.GPADIR.all |= GET_THIRD_BYTE;			// Output
	EDIS;
}

Is there a way to reduce this gaps?

best regards

user4455.

  • In order to study the timings, we need to know the CPU frequency, whether the code is running out of flash or RAM, number of wait states (if flash), and whether prefetching and caching are enabled. We'd also need to look at the generated assembly, not just the C code. Running out of RAM and turning on optimizations should speed things up. If you just want the falling edge of GPIO26 to be closer to the rising edge of the data, you could do something like this:

    const unsigned long int gpio26 = (((unsigned long int) (0x04) << 24) & GET_FOURTH_BYTE);
    unsigned long int data;

    for (loop_counter = 0; loop_counter < array_size; loop_counter++)  {
    data = (((unsigned long int) (data[loop_counter]) << 16) & GET_THIRD_BYTE);
    GpioDataRegs.GPACLEAR.all = gpio26;
    GpioDataRegs.GPASET.all = data;
    ...