printf doesn't work !

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");

Parents
  • 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");
    What the heck is this? Printf needs a format specifier which you omitted, fix that first. The table_drivers[] needs its value placed somewhere. If it is an array of int's then add a %d.

    Goodness, just type this assuming that table drivers is an array of int's and please lookup printf in your C reference.

    printf("\n---------- STDI ----------\n%d\n\n", table_divers[1]);
    I suspect printf works just fine when called properly.

    Regards,

    - Mark

Reply
  • 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");
    What the heck is this? Printf needs a format specifier which you omitted, fix that first. The table_drivers[] needs its value placed somewhere. If it is an array of int's then add a %d.

    Goodness, just type this assuming that table drivers is an array of int's and please lookup printf in your C reference.

    printf("\n---------- STDI ----------\n%d\n\n", table_divers[1]);
    I suspect printf works just fine when called properly.

    Regards,

    - Mark

Children
More questions in this forum