SW006010 Microchip Technology, SW006010 Datasheet - Page 55

no-image

SW006010

Manufacturer Part Number
SW006010
Description
MPLAB 17C SOFTWARE
Manufacturer
Microchip Technology
Datasheets

Specifications of SW006010

Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC17C
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
MPLAB®
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
 2002 Microchip Technology Inc.
2.11.2
The following are simple code examples illustrating the SSP module communicating
with a Microchip 24C080 SPI EE Memory Device. In all the examples provided no error
checking utilizing the value returned from a function is implemented.
#include <p17c756.h>
#include <spi16.h>
// FUNCTION Prototype
void main(void);
void set_wren(void);
void busy_polling(void);
unsigned char status_read(void);
void status_write(unsigned char data);
void byte_write(unsigned char addhigh, unsigned char
void page_write(unsigned char addhigh, unsigned char
void array_read(unsigned char addhigh, unsigned char
unsigned char byte_read(unsigned char addhigh,
unsigned char arraywr[] = {1,2,3,4,5,6,7,8,9,10,11,
//24C040/080/160 page write size
unsigned char far *wrptr = arraywr;
unsigned char arrayrd[32];
unsigned char far *rdptr = arrayrd;
unsigned char var;
#define SPI_CS
//**************************************************
#pragma code _main=0x100
void main(void)
{
WriteSPI (Continued)
Remarks:
Return Value:
File Name:
Code Example:
SPI_CS = 1;
OpenSPI(FOSC_16, MODE_00, SMPEND);
set_wren();
status_write(0);
busy_polling();
set_wren();
byte_write(0x00, 0x61, 'E');
busy_polling();
var = byte_read(0x00, 0x61);
Example of Use
// ensure SPI memory device
// Chip Select is reset
addlow, unsigned char data);
addlow, unsigned char far *wrptr);
addlow, unsigned char far *rdptr,
unsigned char count);
PORTAbits.RA2
This function writes a single data byte out and then checks for
a write collision. This function operates identically to putcSPI.
This function returns -1 if a write collision occurred else a 0 if
no write collision.
writespi.c
WriteSPI(‘a’);
unsigned char addlow);
Hardware Peripheral Library
12,13,14,15,16,0};
apRNOVS^-page 51

Related parts for SW006010