DANKE für den Tipp, komm damit aber nicht zurecht INT8U kennt der
compiler nicht...hab selbst auch noch nicht davon gehört, was ist das
für ein Datentyp?
Ums einfach zu erklären: Ich möchte gerne das ASCII Zeichen "c" senden
und zwar in HEX. Mein Code sieht aus wie folgt.
//----------------------------------------------------------------------
--------------------------
//----------------------------------------------------------------------
--------------
// FID: 33X000035
// Target: C8051F33x
// Tool chain: Keil C51 7.50 / Keil EVAL C51
// Command Line: None
//
// Release 1.0
// -Initial Revision (PD)
// -16 AUG 2006
//
//----------------------------------------------------------------------
-------
// Includes
//----------------------------------------------------------------------
-------
#include <c8051F330.h> // SFR declarations
#include <stdio.h>
//----------------------------------------------------------------------
-------
// Global CONSTANTS
//----------------------------------------------------------------------
-------
#define SYSCLK 24500000 // SYSCLK frequency in Hz
#define BAUDRATE 9600 // Baud rate of UART in bps
//----------------------------------------------------------------------
-------
// Function PROTOTYPES
//----------------------------------------------------------------------
-------
void SYSCLK_Init (void);
void UART0_Init (void);
void PORT_Init (void);
void Timer2_Init (int);
//----------------------------------------------------------------------
-------
// MAIN Routine
//----------------------------------------------------------------------
-------
void main (void)
{
unsigned char inputcharacter; // Used to store character from
UART
PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer
// enable)
PORT_Init(); // Initialize Port I/O
SYSCLK_Init (); // Initialize Oscillator
UART0_Init();
while (1)
{
}
}
//----------------------------------------------------------------------
-------
// Initialization Subroutines
//----------------------------------------------------------------------
-------
//----------------------------------------------------------------------
-------
// PORT_Init
//----------------------------------------------------------------------
-------
//
// Return Value : None
// Parameters : None
//
// Configure the Crossbar and GPIO ports.
//
// P0.4 digital push-pull UART TX
// P0.5 digital open-drain UART RX
//
//----------------------------------------------------------------------
-------
void PORT_Init (void)
{
P0MDOUT |= 0x10; // Enable UTX as push-pull output
XBR0 = 0x01; // Enable UART on P0.4(TX) and
P0.5(RX)
XBR1 = 0x40; // Enable crossbar and weak
pull-ups
}
//----------------------------------------------------------------------
-------
// SYSCLK_Init
//----------------------------------------------------------------------
-------
//
// Return Value : None
// Parameters : None
//
// This routine initializes the system clock to use the internal
oscillator
// at its maximum frequency.
// Also enables the Missing Clock Detector.
//----------------------------------------------------------------------
-------
void SYSCLK_Init (void)
{
OSCICN |= 0x03; // Configure internal oscillator
for
// its maximum frequency
RSTSRC = 0x04; // Enable missing clock detector
}
//----------------------------------------------------------------------
-------
// UART0_Init
//----------------------------------------------------------------------
-------
//
// Return Value : None
// Parameters : None
//
// Configure the UART0 using Timer1, for <BAUDRATE> and 8-N-1.
//----------------------------------------------------------------------
-------
void UART0_Init (void)
{
SCON0 = 0x10; // SCON0: 8-bit variable bit rate
// level of STOP bit is
ignored
// RX enabled
// ninth bits are zeros
// clear RI0 and TI0 bits
if (SYSCLK/BAUDRATE/2/256 < 1) {
TH1 = -(SYSCLK/BAUDRATE/2);
CKCON &= ~0x0B; // T1M = 1; SCA1:0 = xx
CKCON |= 0x08;
} else if (SYSCLK/BAUDRATE/2/256 < 4) {
TH1 = -(SYSCLK/BAUDRATE/2/4);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 01
CKCON |= 0x01;
} else if (SYSCLK/BAUDRATE/2/256 < 12) {
TH1 = -(SYSCLK/BAUDRATE/2/12);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 00
} else {
TH1 = -(SYSCLK/BAUDRATE/2/48);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 10
CKCON |= 0x02;
}
TL1 = TH1; // Init Timer1
TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit
autoreload
TMOD |= 0x20;
TR1 = 1; // START Timer1
TI0 = 1; // Indicate TX0 ready
}
//----------------------------------------------------------------------
-------
// End Of File
//----------------------------------------------------------------------
-------