This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf doesn't work

Hello,

I've a project with two targets, the XC167CI and the C167CR-LM. But if I want the program to print some information with printf, it doesn't work (flash version and sumulationon the XC167CI and the flash version for the C167...).

The initialization must be correct (I hope so)

/* defines for XC167CI */
#define S0TIC ASC0_TIC
#define S0RIC ASC0_RIC
#define S0BG  ASC0_BG
#define S0CON  ASC0_CON


void initSerial(void) {
  P3  |= 0x0400;
  DP3 |= 0x0400;
  DP3 &= 0xF7FF;
  S0TIC = 0x80;
  S0RIC = 0x00;
  #ifdef XC167
    S0BG = 0x81;
  #endif
  #ifdef C167
    S0BG = 0x40;
  #endif
  S0CON = 0x8011;
  #ifdef XC167
    ALTSEL0P3 |= 0x0C00;
  #endif
}

Moreover I've changed the startup code with
SSTSZ   EQU     0x50
...
USTSZ   EQU     0x50
...
MOV     STKUN,#0FFFEH  ; AVOID STKUN TRAP
MOV      STKOV,#0H     ; AVOID STKOV TRAP
   ;MOV     STKUN,#SOF (_TOS)
   ;MOV     STKOV,#SOF (_BOS+6*2)
   ;MOV     SP,#SOF (_TOS)
   ;MOV     SPSEG,#SEG (_TOS)

Where can be the bug? I already tried so much but can't find the problem.

Thank You
Norbert Rastl

PS.: memory model = "MEDIUM"

Parents
  • I think the memory model will not be the critical point, since you could use different
    keywords like huge or xhuge ...

    I think that memory settings are the reason.
    printf() was crashing my system, only in the case where I adjusted wrong timing for RAM access.

    BTW: Should not the setting for an XC16x device looks like

    ROM 0x040000 size 0x3FFF
    RAM 0x100000 size 0x3FFF

    Stefan

Reply
  • I think the memory model will not be the critical point, since you could use different
    keywords like huge or xhuge ...

    I think that memory settings are the reason.
    printf() was crashing my system, only in the case where I adjusted wrong timing for RAM access.

    BTW: Should not the setting for an XC16x device looks like

    ROM 0x040000 size 0x3FFF
    RAM 0x100000 size 0x3FFF

    Stefan

Children
  • What would be the better settings for a C167CR-LM?

    I now use the startup code in version 5.01. And everything runs perfectly in with the simulator but not on the chip. It does nothing. It does not even write a character after initializing the serial interface.

    Can it be that the On-chip XRAM makes problems?