I don't know why, I would like to implement a printf function in my C program for my T89C51CC01. When I run the debugger, my program stop during the execution of the printf function. The manual say that printf use the putchar function. OK. I try to take a look on the disassembly windows, and the program stop just when it tries to send the first character of my string. This is a sample of my program:
void main(void) { while(1) { // Fonctionnement normal // Mode de configuration modeConfig = 1; init_mode_config(); TR0 = 1; while(modeConfig == 1) { switch(niveauMenu) { // Attente des caractères CR,CR pour activer le menu case 0x00: if(flgDataRecu) // Test si le mode config a bien été demandé ? { // Attente de 2 CR flgDataRecu = 0; if(cara_recu == CR) { temps = 0; if(flgDemandeMenu == 1) { TR0 = 0; niveauMenu = 0x01; } else flgDemandeMenu = 1; } else { if(flgDemandeMenu == 1) flgDemandeMenu = 0; // Mauvais caractère ! } } break; // Menu principal case 0x01: printf("\n---------- STDI ----------", table_divers[1], "\n\n"); // printf("A - Vitesse de Transmission serie\n"); printf("B - Format des Donnees\n");
I forget to tell you that my program stop at the beginning of the case 0x01: when the execution of the printf begin...
First, fix your indenting please. 4 spaces (never tabs!) per indent only. This is my law, I expect the world to abide by it. :-) Second,
printf("\n---------- STDI ----------", table_divers[1], "\n\n");
printf("\n---------- STDI ----------\n%d\n\n", table_divers[1]);
Hi Mark, thanks for your help! (I'm agree with you about the indenting but my copy and paste do that) the
table_divers[1]
void main(void) { while(1) { // Fonctionnement normal // Mode de configuration modeConfig = 1; init_mode_config(); TR0 = 1; while(modeConfig == 1) { switch(niveauMenu) { // Attente des caractères CR,CR pour activer le menu case 0x00: . . . break; // Menu principal case 0x01: ES = 0; TI = 1; printf("\n---------- STDI ----------", table_divers[1], "\n\n"); printf("A - Vitesse de Transmission serie\n"); printf("B - Format des Donnees\n"); . . . .
printf("\n---------- STDI ----------%s\n\n", table_divers[1]);
That's right! I write a serial ISR in my program! OK i understand better the putchar function and my ISR are in conflict. OK Sorry for my mistake about the printf parameter, your're right again. Thanks a lot, it will be easier now.
Extra arguments in the call to printf are ignored if there are no format specifiers. So it could not be the problem. - Mike
Right! That's what's happened to me, but I corrected it now...