2023-04-07 05:08 AM
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
Solved! Go to Solution.
2023-04-07 05:15 AM
Make it volatile if it changes content whilst running, this will force the compiler to reload the value each time.
2023-04-07 05:15 AM
Make it volatile if it changes content whilst running, this will force the compiler to reload the value each time.
2023-04-07 06:08 AM
made the read pins volatile pointers and it exits the loops now