Need help on linking PCB board to hyperterminal using serial port

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

Need help on linking PCB board to hyperterminal using serial port

Jump to solution
3,575 Views
admin
Specialist II
Hi. I'm using codewarrior v6.0, and MC9S08AW60 mcu. I need help on writing a program to link my board to the hyperterminal. I'm using a serial cable to link the 2 devices. Thx


Message Edited by Cryptical on 2009-01-14 05:43 AM
Labels (1)
Tags (1)
0 Kudos
1 Solution
623 Views
admin
Specialist II
I've finally managed to get it working with the help of a colleague :smileyhappy:
What i was missing is to open the RS485 ports on the PCB board.
Here's the code to display "#" on hyperterminal
 
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
void main(void)
     {
      PTFDD_PTFDD6=1; //RS485_PIN_MODE
      PTFD_PTFD6=1; //RS485_TX_ENABLE
      SCI1BD=0x001A;
      SCI1C1=0x00;
      SCI1C2=0x0C;     
     
      for(;:smileywink:
      {
       __RESET_WATCHDOG();
       SCI1D = 0x23;
       while ((SCI1S1 & 0x80) == 0);
      }
     }

View solution in original post

0 Kudos
5 Replies
624 Views
admin
Specialist II
I've finally managed to get it working with the help of a colleague :smileyhappy:
What i was missing is to open the RS485 ports on the PCB board.
Here's the code to display "#" on hyperterminal
 
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
void main(void)
     {
      PTFDD_PTFDD6=1; //RS485_PIN_MODE
      PTFD_PTFD6=1; //RS485_TX_ENABLE
      SCI1BD=0x001A;
      SCI1C1=0x00;
      SCI1C2=0x0C;     
     
      for(;:smileywink:
      {
       __RESET_WATCHDOG();
       SCI1D = 0x23;
       while ((SCI1S1 & 0x80) == 0);
      }
     }
0 Kudos
623 Views
admin
Specialist II
Hi Stanish. Thx for the reply. I have tried using the processor expert to send and receive data from the hyperterminal, but I don't think its working for me yet. I managed to find the AsynchroSerial bean but not the CPU bean. I've attached a picture below to show you my settings for the AsynchroSerial bean. Right now I'm just a student attached to a company, and I'm tasked to send and receive data using the RS-232 hyperterminal. For example, if I type "2" on my hyperterminal, the MCU will return me a "4" and display it on my hyperterminal too. I only have 2 weeks of experience on this hardware lol.
 
To be frank, I hope you could explain step-by-step on how to make this work. I have confirmed I'm using SCI1 port, and my hyperterminal settings are bps=9600, databits=8, parity=none, stopbits=1, flowcontrol=none. I've also confirmed I'm able to send data to the MCU by using the code I posted, but I'm not able to make the MCU return me data and display it on my hyperterminal.
 
Many thanks for your time, and here's the AsynchroSerial bean pic, just click on the picture once to zoom in:
 
0 Kudos
623 Views
admin
Specialist II
Hi Stanish. Thx for the reply. I'm not so sure about your method, as the sample code I got from another person is quite different from yours. Here's the sample code:
 
/*********************************************************************/
/* Project Name: SCI.mcp                                             */
/* Source fle name: SCI.c                                            */
/*********************************************************************/
/* Copyright (C) 2007 Freescale Semiconductor, Inc.                  */
/* All Rights Reserved                                               */
/*********************************************************************/
/*********************************************************************/
/* Hands on training for QE128 MCU's                                 */
/* Module: SCI                                                       */
/* The firmware was developed and tested on CodeWarrior 6.0 version  */
/*                                                                   */
/* Description: The SCI module is configured to work at 9600bps,     */
/* in 8-bit mode and normal operation. When an interrupt is          */
/* generated the received data is display on PTE port and one byte   */
/* is send by SCI                                                    */
/*********************************************************************/
/*                                                                   */
/* Date: 12/03/2007                                                  */
/* Ulises Corrales Salgado                                           */
/* Application Engineer                                              */
/* RTAC Americas                                                     */
/*********************************************************************/                                                                     
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
typedef unsigned char UINT8;
/*********************************************************************/
/*  Function declarations                                            */
/*********************************************************************/
void MCU_Init(void) {
 
 SOPT = 0x23;          /* Watchdog disable. Stop Mode Enable. Background Pin enable. RESET pin enable */ 
 ICGC1 =0x28;
 ICGC2=0x31;
 while(!ICGS1_LOCK);
}
void GPIO_Init(void) {
 
  PTCDD = (UINT8) (PTCD | 0x3F);          /* Configure PTC0-PTC6 as outputs */
  PTEDD = (UINT8) (PTED | 0xC0);          /* Configure PTE6 and PTE7 pins as outputs */
  PTCD = 0x3F;           /* Put 1's in port C in order to turn off the LEDs */
  PTED = 0xC0;           /* Put 1's in port E port in order to turn off the LEDs */
}
void SCI_configuration (void) {
 
  SCI2C1 = 0x00;        /* 8-bit mode. Normal operation */
  SCI2C2 = 0x2C;        /* Receiver interrupt enable. Transmitter and receiver enable */
  SCI2C3 = 0x00;        /* Disable all errors interrupts */
  SCI2BDL = 0x1A;       /* This register and the SCI1BDH are used to configure the SCI baud rate */
  SCI2BDH = 0x00;       /*                    BUSCLK               4MHz                */
                        /* Baud rate = -------------------- = ------------ = 9600bps   */
}                       /*               [SBR12:smileyfrustrated:BR0] x 16        26 x 16              */
/*********************************************************************/
/*  Main Function                                                    */
/*********************************************************************/
void main(void) {
  MCU_Init();       /* Function that initializes the MCU */     
  GPIO_Init();      /* Function that initializes the Ports of the MCU */
  SCI_configuration();  /* Function that initializes the SCI module */
  EnableInterrupts; /* enable interrupts */
     
  for(;:smileywink: {
 
  } /* loop forever */
  /* please make sure that you never leave this function */
}
void interrupt VectorNumber_Vsci1rx SCI_RX_ISR(void) {
 UINT8 temp;
 SCI1S1_RDRF = 0;       /* Receive interrupt disable */
 temp = SCI1D;          /* Display on PTE the received data from SCI */
 PTED = (UINT8) (temp & 0xC0);         /* Move the received value to port E */
 PTCD = (UINT8) (temp & 0x3F);         /* Move the received value to port C */
 while (SCI1S1_TDRE == 0);  /* Wait for the transmitter to be empty */
 SCI1D = '1';               /* Send a character by SCI */
}
 
If you have time, kindly take a look and comment on it. Thx =)
0 Kudos
623 Views
stanish
NXP Employee
NXP Employee
Cryptical,

I was not sure what exactly you are asking about. My suggestion would allow your application to use console I/O functions e.g printf, scanf.
According to the source code it seems your question is related to low lever SCI drivers.

You can use Processor Expert tool to generate low level SCI drivers e.g to send byte, receive byte via SCI.
To create Processor Expert project under CW simply create new project using Project Wizard
select derivative you are using  (MC9S08AW60) and enable "Processor Expert" option.

Then configure "CPU bean" clock settings and add&configure AsynchroSerial bean.
Press "make" and the SCI routines will be generated (AS1.c module) and compiled.

Stanish
0 Kudos
623 Views
stanish
NXP Employee
NXP Employee
Cryptical,

Not sure I undersood your question.

I'd suggest you to use standard ANSI-C functions printf(), scanf(). In order to redirect inputs/outputs to hyperterminal console you have to implement SCI get char and put char  functions. There are callback functions

char TERMIO_GetChar(void)
void TERMIO_PutChar(char ch)

and init function prototype:

void TERMIO_Init(void)

declarations are located in <termio.h>

See below the possible implementation:
main.c (snippet of code)
...
#include <stdio.h>
#include <termio.h>

char TERMIO_GetChar(void) /*scanf*/
{
 char ch;
 AS1_RecvChar(&ch);
 return (ch);
}


void TERMIO_PutChar(char ch)
{
  AS1_SendChar(ch);
}

void TERMIO_Init(void){

/* Initialize SCI */
}

void
void main(void)
{

 
  TERMIO_Init();

  printf ("Hello World!");

...

You can use SCI functions generated by ProcessorExpert AsynchroSerial bean as I did.


Stanish