File "scidemo.c"
Full Path: /home/analogde/www/68hc11/68HC12/scidemo.c
File size: 2.78 KB
MIME-type: text/x-c
Charset: utf-8
5a0
HTTP/1.1 200 OK
Date: Sat, 18 Jun 2005 20:13:45 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_perl/1.26 mod_ssl/2.8.9 OpenSSL/0.9.6g PHP/4.1.2
Last-Modified: Wed, 08 Jan 2003 19:43:49 GMT
ETag: "cac4a4-9ba-3e1c7f75"
Accept-Ranges: bytes
Content-Length: 2490
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/x-csrc
// filename SCIDEMO.C
// Jonathan W. Valvano, 12/21/02
// This is a good starter file if you use serial I/O
// PortS SCI Port0 serial I/O
// COP reset will be disabled by COPCTL=0;
// Copyright 2003 by Jonathan W. Valvano, valvano@uts.cc.utexas.edu
// You may use, edit, run or distribute this file
// as long as the above copyright notice remains
#include "HC12.h"
#include "SCI12.H"
// These variables should be local, but
// I placed as global to assist in debugging
char string[10];
unsigned short n;
//**************Init**************
// Initialize PortT and timer
void Init(void){
COPCTL = 0x00; // disable COP
DDRT |= 0x40; // PortT bit 6 is output to LED
TSCR = 0x80; // TEN(enable)
}
//*****************OutCRLF***************
// Output a CR,LF to go to a new line
// toggle PortT bit 6 each time, debugging profile
void OutCRLF(void){
SCI_OutChar(CR);
SCI_OutChar(LF);
PORTT ^= 0x40; // toggle bit 6
}
//*****************OutSPSP***************
// Output two spaces
void OutSPSP(vo
41a
id){
SCI_OutChar(SP);
SCI_OutChar(SP);
}
//*****************Display***************
// Display 16-bit number in all three formats
void Display(short number){
SCI_OutString(" OutUDec="); SCI_OutUDec(number);
SCI_OutString(" OutSDec="); SCI_OutSDec(number);
SCI_OutString(" OutUHex="); SCI_OutUHex(number);
OutCRLF();
}
void main(void){
Init(); // initialize COP, Port T
SCI_Init(13);
SCI_OutString("Adapt812 SCI demo 12/21/02 -JWV"); OutCRLF();
Display(0x8000);
Display(-32767);
Display(-32766);
Display(-1);
Display(0);
Display(32765);
Display(32766);
Display(32767);
while(1){
SCI_OutString("InString: ");
SCI_InString(string,10); OutSPSP(); SCI_OutString(string); SCI_OutChar(SP);
n=0;
while(string[n]){
SCI_OutChar(SCI_UpCase(string[n]));
n++;
}
OutSPSP();
SCI_upCaseString(string); SCI_OutString(string); OutCRLF();
SCI_OutString("InUDec: "); n=SCI_InUDec(); Display(n);
SCI_OutString("InSDec:
0
"); n=SCI_InSDec(); Display(n);
SCI_OutString("InUHex: "); n=SCI_InUHex(); Display(n);
}
}
#include "SCI12.C"
// SCI12.C uses gadfly synchronization
// SCI12a.C uses interrupt synchronization
extern void _start(); /* entry point in crt12.s */
#pragma abs_address:0xfffe
void (*reset_vectors[])() = { _start };
#pragma end_abs_address