Sprintf not working with dragon12-light board(C)

72 Views Asked by At

I'm trying to program a Dragon12-Light board to display information to a PC through Cool Term terminal software, however I can't seem to get the sprintf function to work properly. The goal is to send information from the temperature sensor and light sensor to the terminal, but I've even tried it with dummy values and it's not operating properly. Here's the code:

void main(void) {
  PLL_init();        // set system clock frequency to 24 MHz 
  DDRB  = 0xff;       // Port B is output
  DDRJ  = 0xff;       // Port J is output
  DDRP  = 0xff;       // Port P is output
  PTJ = 0x00;         // enable LED
  PTP = 0x00;         // enable all 7-segment displays
  PORTB   = 0x55;     // turn on every other led and segment on 7-seg displays
  initSCI0();


  for(;;) {

  unsigned char pot = '1';
  unsigned char pot_out;
  unsigned char temperature;
  unsigned char light;
  unsigned char receive;
  char buffer[50];
  int test = 10;

  sprintf(buffer, "test = %d", test);

  receive = SCI0_receiveByte();

  if(receive == '1'){


  SCI0_transmitString(buffer);

  }


  } /* wait forever */
}

I've verified that all functions operate properly, and if I put a char array with a defined value into the transmit string function, it will display properly on the terminal when '1' is pressed on the keyboard, but the sprintf command doesn't seem to be writing anything to the array. Any help would be greatly appreciated. Thanks!

0

There are 0 best solutions below