Sin el modificador volatile
y cuando se compila con la optimización -O3
;
el valor de fineOffset
permanece igual, a menos que se descomente
el printf que lo usa, por ejemplo.
Created
April 10, 2014 22:41
-
-
Save dvdvck/10429610 to your computer and use it in GitHub Desktop.
por qué fineOffset es vólatil?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void signaling(){ | |
static char unsigned line = 0; | |
//porque es volatil fineoffset? | |
char unsigned col, coarseOffset; | |
char unsigned volatile fineOffset; | |
unsigned char data_r1, data_r2; | |
//scanning 1/16 | |
col = (COLUMNS >> 3) - 1; | |
do{ //cols | |
coarseOffset = (line << 3) + 7 - col; | |
// printf("\ncoarse:%d\t", coarseOffset); | |
data_r1 = *(frameBuffer + coarseOffset); | |
data_r2 = *(frameBuffer + coarseOffset + channelOffset); | |
fineOffset = 0; | |
do{ | |
//TODO: UN SOLO WRITE PARA R1 Y R2 | |
dWrite(sk, 0); | |
// printf("fine: %d", fineOffset); | |
dWrite(r1, !(data_r1 >> fineOffset & 1)); | |
dWrite(r2, !(data_r2 >> fineOffset & 1)); | |
dWrite(sk, 1); | |
}while(fineOffset++ < 7); | |
}while(col--); | |
dWrite(en, 1); | |
dWrite(lt, 0); | |
dWrite(la, line & 1); | |
dWrite(lb, line >> 1 & 1); | |
dWrite(lc, line >> 2 & 1); | |
dWrite(ld, line >> 3 & 1); | |
dWrite(lt, 1); | |
dWrite(en, 0); | |
if(line == 0){ | |
line = LINES - 1; | |
}else{ | |
line--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment