?? pec.c
字號:
/*---------------------------------------------------------
PECDEF reserves space for PEC channel 0 pointers. Note
that this must be the first line of the program.
---------------------------------------------------------*/
#pragma PECDEF (0)
#include <reg167.h>
#include <intrins.h>
#include <stdio.h>
#include <string.h>
const char string1 [] = "0123456789\n";
/*---------------------------------------------------------
This function initializes PEC Channel 0 to move the data
from STRING1 to the serial transmit buffer.
---------------------------------------------------------*/
void serial_PEC0_setup (void)
{
PECC0 = 0x0500 | strlen (string1); // Move Bytes, Inc Src Ptr
SRCP0 = _sof_ (string1); // Source is STRING1
DSTP0 = (unsigned int) &S0TBUF; // Destination is the serial output
}
/*---------------------------------------------------------
The Serial TX interrupt just resets PEC 0 and transfers
another copy of STRING 1.
---------------------------------------------------------*/
void serial_TX_irq (void) interrupt S0TINT = 42
{
serial_PEC0_setup ();
}
/*---------------------------------------------------------
The setup routine for the serial port initializes the
PEC 0 transfer and sets a TX interrupt request.
---------------------------------------------------------*/
void serial_setup (unsigned int baud)
{
// Setup the Baudrate
S0BG = (20000000UL / (32UL * (unsigned long) baud)) -1;
P3 |= 0x0400; // Set TXD high
DP3 |= 0x0400; // Set TXD for output
DP3 &= ~0x0800; // Set RXD for input
S0CON = 0x8011;
S0TIC = 0x00F8; // Serial TX IRQ = Level 14, Priority 0 (PEC 0)
serial_PEC0_setup ();
IEN = 1; // Enable interrupts
}
/*---------------------------------------------------------
Main C Function
---------------------------------------------------------*/
void main (void)
{
serial_setup (19200);
while (1)
{
}
}
/*---------------------------------------------------------
---------------------------------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -