2011-04-13 10:30 AM
STM8L GPIO initialization slow?
2011-05-17 06:12 AM
Hi Marc,
I can suggest to write directly in GPIO control registers. You need to set the GPIOx->CR1 CR2 DDR ... The best way is to analyze the function and check the setted bits and write directly in the GPIO control registers. The driver functions are generic and test the different cases. In you case you know your pin configuration --> do it, without the different cases. I test it with a code someting like that quickly the results seems interesting:// GPIO_Init(OW_PORT, OW_PIN, GPIO_Mode_Out_PP_Low_Fast); //define as output
GPIOE->ODR = 0;
GPIOE->DDR =0x80; // pin 7 output GPIOE->CR1 =0x80; // PUSH PULL GPIOE->CR2 =0x00; // SLOW FAST // GPIO_ResetBits(OW_PORT, OW_PIN); //set low GPIOE->ODR = 0x80; // set GPIOE pin7 to 1_delay_us(5);
// GPIO_Init(OW_PORT, OW_PIN, GPIO_Mode_In_PU_No_IT) //define as input GPIOE->ODR = 0; GPIO-GPIOE->CR2 = 0; // no interrupt GPIOE->DDR = 0; // PIN7 INPUT GPIOE->CR1 =0x80; // PIN 7 PULL UP _delay_us(5);}
I think that this example reply to your request, let me know. Rgds Phil2011-05-17 06:12 AM
Hi Phil,
thank you. I've tested it. It's faster, but still not fast enough. The high / low signals are now 18 microseconds. Do you have other suggestions?
Thanks
2011-05-17 06:12 AM
GPIOE->ODR = 0;
GPIOE->CR2 =0x0; GPIOE->CR1 =0x80; while(1){ GPIOE->DDR =0x80; // pin 7 output _delay_us(5); GPIOE->DDR = 0; // PIN7 INPUT _delay_us(5); }2014-11-03 07:04 AM
Hi Phil, Hi Marc,
Is the problem identified with the GPIO response times.? I used the functions GPIO_Init with GPIO_MODE_OUT_PP_LOW_FAST for o/p &GPIO_MODE_IN_FL_IT
for i/p which is supposed to 10Mhz, and the GPIO_WriteHigh & GPIO_WriteLow as well as GPIO_ReadInputPin. Each of these functions are directly writing to the registers GPIOX->ODR. But the response time is painfully slow. I have configured my clock as 16Mhz & using HSI oscillator. In a while loop when i light an led depending on the state of a GPIO pin configured as i/p, there seems to be a distinct lag of around 1-2secs, which is surprising It's the same even when i light the led in an interrupt service routine Do you any idea as to why this could be happening I am using STM8S-Discovery board & SDCC compiler & STVP flash tool