Skip to main content
VNdir.1
Associate
April 7, 2023
Solved

I am stuck in the condition of a while loop when I am debuging

  • April 7, 2023
  • 1 reply
  • 1569 views
void capture(Adafruit_OV7670 *platform){
		uint32_t i =platform->bufferSize;
		uint16_t *shot =platform->buffer;
		uint8_t* pclk = platform->pins.pclk.Read_reg;
		uint8_t* vsync = platform->pins.vsync.Read_reg;
		uint8_t alt = 0;
		while(alt==0){
			alt=*vsync;
		}
 
		//while(!OV7670_pin_read(platform->pins.hsync));
		while(i-- >1){
			shot[i]=0;
			uint8_t j = 16;
			alt=*pclk;
			while(alt==0){
				alt=*pclk;
			}
			while(j-- > 9)
				shot[i]|= (OV7670_pin_read(platform->pins.data[j-8]))<<j;
			/*while(alt!=0){
				alt=*pclk;
			}*/
			while(alt==0){
				alt=*pclk;
			}
			while(j-->1)
				shot[i]|= (OV7670_pin_read(platform->pins.data[j]))<<j;
			/*while(alt!=0){
				alt=*pclk;
			}*/
		}
}

"pins" is an array of Band pins, a strut defined in gpio.h. All the variables that assign their value to the variable "alt" map to the allias of bits of IDR registers. I am using nucleo-144 stm32f439zi. Everything is wired correctly and my main problem is that I am stuck in the condition part of the loop in line 24. It works when there is no optimisation but not when it is optimized for speed . The toolchains used were ARM 3021 and stm32 10.3-2021-10

This topic has been closed for replies.
Best answer by Tesla DeLorean

Make it volatile if it changes content whilst running, this will force the compiler to reload the value each time. ​

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
April 7, 2023

Make it volatile if it changes content whilst running, this will force the compiler to reload the value each time. ​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
VNdir.1
VNdir.1Author
Associate
April 7, 2023

made the read pins volatile pointers and it exits the loops now