Oroitz Elgezabal

Prinf() doesn't work

Discussion created by Oroitz Elgezabal on Oct 25, 2006
Latest reply on Oct 31, 2006 by no name
Hi,
 
I wrote a message yesterday related with serial communication using MC9S12C32. I have been working quite tought with this, but I haven't succeed, here is my code, can anyone tell what is what I'm doing wrong?  what it doesn't work is the printf () sentence all the rest works. I'm using Imagecraft's ICC12 compiler+chips12 demoboard.
 
PD: ledon(), ledoff() & delay_ms() functions defined in the ofunc.h file
 

//Include files
#include <mc9s12c32.h>
#include "ofunc.h"
#include <stdio.h>

//MACROS DEFINITIONS
#define ENABLE_INTERRUPTS asm("cli")

//Definition of variables
short start=1, on=0;
char mensaje[]="hello world\n";


//Definition of functions
void SCItx(unsigned char SCIByte){
      SCIDRL = SCIByte;
/*Write data byte to SCIDRL register*/
       SCICR2 |= 0x80;
/*Enable TDRE interrupt*/
}

//Definition of interrupt service routines
#pragma interrupt_handler SCIhdr
extern void SCIhdr();
void SCIhdr(void){

//--------------------------Byte Transmision-------------------------------
       if (SCISR1 & 0x80){
               SCISR1;
               SCICR2&=0x7F;
      }
//if (SCISR1 & 0x80)
//-----------------------End of Byte Transmision---------------------------

//--------------------------Byte Reception---------------------------------
       if (SCISR1 & 0x20){
//Received data available in SCI data register
                SCISR1;
//Reading of SCISR1 needed to clear RDRF
                if(SCIDRL=='0'){
                       ledoff(2);
                       ledon(3);
                       SCItx('\n');
               }
               if (SCIDRL=='1'){
                       ledoff(3);
                       ledon(2);
               }
      }
//if (SCISR1 & 0x20)
//-----------------------End of Byte Reception-----------------------------
return;
}


//======================= Program´s main body ==================================
main(){

//SCI module configuration
SCIBDH=0x00; SCIBDL=0x1A;
//Baud rate=19.200
SCICR1=0x00;
//8 data bits & no parity
SCICR2 = 0xAC;
//Enable Tx, Rx, and RDRF interrupt
SCISR1;
//Port AD pins set as general porpouse outputs
DDRAD=0xFF;
//Switch on the led connected to PAD4 (LED2)
ledon(2);

//Enable interrupts
ENABLE_INTERRUPTS;
 
    while (1){
        if (start==1){
             SCItx('p');
             printf("Hola\r\n");
             start=0;
        }
        if (on==0){
             ledon(1);
             on=1;
        }
        else {
             ledoff(1);
             on=0;
             SCItx('A');
         }
        delay_ms(500);
    }
//While(1)
}
//main

 

THANK YOU VERY MUCH IN ADVANCE

Oroitz

Outcomes