cancel
Showing results for 
Search instead for 
Did you mean: 

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

VNdir.1
Associate II
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

1 ACCEPTED SOLUTION

Accepted Solutions

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

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