CodeWarrior 4.6 printf() and P & E BDM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CodeWarrior 4.6 printf() and P & E BDM

Jump to solution
3,328 Views
wongmld
Contributor I
Hi all,

I need to use the printf() command to print to the testterm window when debugging through the BDM.

I have use the following code fragments to initialize:

#include
#include

#define NOCHAR -1

typedef struct {
unsigned char SCxBDH;
unsigned char SCxBDL;
unsigned char SCxCR1;
unsigned char SCxCR2;
unsigned char SCxSR1;
unsigned char SCxSR2;
unsigned char SCxDRH;
unsigned char SCxDRL;
} SCIStruct;

/* terminal.wnd */
#define SCI_ADDR 0x00c8
#define SCI (*((SCIStruct*)(SCI_ADDR)))

and here is my TERMIO_PutChar:
void TERMIO_PutChar(char ch) {
/* sends a character to the terminal channel */
while (!(SCI.SCxSR1 & 0x80)); /* wait for output buffer empty */
SCI.SCxDRL = ch;
}

However, I can't get the output from my TERMINAL OR TESTTERM windows. What should be the port setting for Virtual SCI? SCI.Output and SCI.Input? When I look up in the Inspector module, I found there is two SCIs objects, namely Sci0 and SCI. However both of them are not memory mapped object.

Any pointers would be greatly appreciated.

Thanks.
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,010 Views
CrasyCat
Specialist III
Hello
 
Only thing you can try is open a Terminal Component and select "Serial port" as Default Configuration.
Then select the appropriate serial port and baud rate on the bottom of the configuration window.
 
make sure to connect your board SCI with your Host COM port and you should be able to see output from printf in the Terminal window.
 
If this does not work, you will need to open a HyperTerminal window to see printf.
In both cases you need to connect target board SCI with your Host COM port to see output.
 
Virtual SCI is not enabled for P&E connection.
 
CrasyCat

View solution in original post

0 Kudos
Reply
4 Replies
1,011 Views
CrasyCat
Specialist III
Hello
 
Only thing you can try is open a Terminal Component and select "Serial port" as Default Configuration.
Then select the appropriate serial port and baud rate on the bottom of the configuration window.
 
make sure to connect your board SCI with your Host COM port and you should be able to see output from printf in the Terminal window.
 
If this does not work, you will need to open a HyperTerminal window to see printf.
In both cases you need to connect target board SCI with your Host COM port to see output.
 
Virtual SCI is not enabled for P&E connection.
 
CrasyCat
0 Kudos
Reply
1,010 Views
GordFinlay
Contributor I
CrasyCat:
 
Is there a reason that Virtual SCI over the BDM cable seems to be possible with CW for HCS12 V4.6 for the Abatron BDI cable but not for the P&E Multilink/Cyclone Pro cables? There is example code with CW 4.6 for doing terminal i/o with the Abatron BDI with output going to the terminal component window. See the TERMBGND.C file for the "Calculator - Ram" example.
 
I believe that it might be possible to do console I/O over BDM with the P&E Multilink cable and the Codewarrior HIWAVE debugger. I see that the 3rd party tool called the NoIce debugger from John Hartman (see http://www.noicedebugger.com/68hc12.html) has a Virtual SCI feature which works over BDM with the P&E Micro multilink cable.
 
Here is a short excerpt from the TERMBGND.c which shows how the terminal i/o ram buffer on the target is used to perform i/o to the terminal component. I believe that WSPADR is also used to define a terminal i/o buffer when HIWAVE uses D-Bug12 over a serial cable rather than BDM.
 
/* This module is used for the terminal emulation. It will allow
   HI-WAVE to communicate through the BDM interface with an application
   running on the target system */
  
#ifndef WSPADR           /* if not defined on the command line */
#define WSPADR   0x2000   /* define work space for HC912DG128 */
#endif
typedef struct {
   unsigned char rxFlag;
   unsigned char rxChar;
   char*         txBuffer;
} TermDataT;

#define  TermData (*((TermDataT*)(WSPADR)))
static char txBuffer[2];
char GetChar(void)
{
  char rxChar;
 
  while (TermData.rxFlag == 0); /* wait for input */  
  rxChar = TermData.rxChar;
  TermData.rxFlag = 0;
  return rxChar;
}
void PutChar(char ch)
{
  txBuffer[0] = ch;
  txBuffer[1] = 0;
  TermData.txBuffer = txBuffer;
  while (TermData.txBuffer != 0); /* wait for output buffer empty */    
}
0 Kudos
Reply
1,010 Views
CrasyCat
Specialist III
Hello
 

Virtual SCI over the BDM cable is a feature available in the BDI firmware.
There is no similar feature available in the P&E firmware (as far as I know).

So if you are debugging though Multilink or Cyclone Pro cable you need to rediect stdio to a SCI port and get the output from there.

CrasyCat
0 Kudos
Reply
1,010 Views
wongmld
Contributor I
Thanks very much.
0 Kudos
Reply