Byte Craft COP8C Tutorial
Table of Contents
I.
Using the Compiler
1.
Simple Example
2.
I/O Ports
3.
Application Startup and Initialization Code
The compiler and initialization
The
__STARTUP()
function
The startup library
4.
Programming with the COP8 Interrupts
Writing interrupt subroutines
Saving compiler temporary variables
5.
Declaring Variables
Variables and memory usage
Finding variable information
Specifying where a variable is allocated
Local variables
6.
Mixing Assembly with C
Integrating C and assembly
Assembly within C
Creating a function in assembly
Calling C from assembly
C variables and assembly
II.
Byte Craft Sample Applications
7.
Flash COP8 Sample Application
III.
Byte Craft COP8C Frequently-asked Questions
8.
Frequently-asked Questions
IV.
Byte Craft Embedded C Library Reference
I.
CTYPE
isalnum
— tests for alphabetic or numeric characters
isalpha
— tests for alphabetic characters
isascii
— tests for
ASCII
characters
iscntrl
— tests for control characters
isdigit
— tests for digit characters
islower
— tests for lower-case characters
isupper
— tests for upper-case characters
isxdigit
— tests for hexadecimal digits
toascii
— converts a character to
ASCII
tolower
— converts an upper-case character to lower-case
toupper
— converts a lower-case character to upper-case
II.
LCD Library
LCD Library Configuration
— definitions for the LCD routines
lcd_putch
— writes to the LCD panel
lcd_getch
— reads from the LCD panel
lcd_gotoXY
— moves the insertion point
lcd_init
— initialize the LCD display
lcd_send_control
— sends a control character to the LCD display
busy_check
— waits until the LCD is available
III.
PORT Library
DDR
— set a I/O port's data direction register
IV.
STDIO
gets
— stores input characters to a buffer
puts
— outputs characters from a buffer
V.
Standard Library
abs
— returns the absolute value
ahtoi16
— converts hexadecimal string to integer
ahtoi8
— converts hexadecimal string to integer
atoi16
— converts string to integer
atoi8
— converts string to integer
labs
— returns the absolute value
i16toa
— converts integer to string
i8toa
— converts integer to string
ui16toa
— converts integer to string
ui8toa
— converts integer to string
pow
— raise base to exponent
qsort
— sorts elements in an array
srand
— set the random number generation seed
randomize
— set the random number generation seed
rand
— generate a pseudorandom integer
VI.
String Library
memchr
— searches for a character in memory
memcpy
— copies memory contents
sizeof
— Calculate the size of a variable
size_t
— type returned by the
size_of
function
memcmp
— compares two arrays
strcat
— copies one null-terminated string to another
strchr
— searches a null-terminated string
strcmp
— compares two null-terminated strings
strcpy
— copies a null-terminated string
strlen
— returns the length of a string
strset
— fills a string with a character
strupr
— converts a string to upper case
strlwr
— converts a string to lower case