SW006010 Microchip Technology, SW006010 Datasheet - Page 43

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.8.2
The following are simple code examples illustrating the SSP module communicating
with a Microchip 93LC66 Microwire EE Memory Device. In all the examples provided
no error checking utilizing the value returned from a function is implemented.
#include "p17c756.h"
#include "mwire16.h"
// 93LC66 x 8
// FUNCTION Prototype
void main(void);
void ew_enable(void);
void erase_all(void);
void busy_poll(void);
void write_all(unsigned char data);
void byte_read(unsigned char address);
void read_mult(unsigned char address, unsigned char
far *rdptr, unsigned char length);
void write_byte(unsigned char address, unsigned char data);
unsigned char arrayrd[20];
unsigned char far *rdptr = arrayrd;
unsigned char var;
// DEFINE 93LC66 MACROS
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#pragma code _main=0x100
void main(void)
{
}
void busy_poll(void)
{
}
void write_byte(unsigned char address, unsigned char data)
W_CS = 0;
OpenMwire(FOSC_16);
ew_enable();
write_byte(0x13, 0x34); //write byte (address,data)
busy_poll();
Nop();
byte_read(0x13);
read_mult(0x10, rdptr, 10); //read multiple bytes
erase_all();
CloseMwire();
W_CS = 1;
do
{
var = DataRdyMwire();
}while(var != 0);
W_CS = 0;
Example of Use
READ
WRITE 0x0A
ERASE 0x0E
EWEN
EWEN
ERAL
ERAL
WRAL
WRAL
EWDS
EWDS
W_CS
0x0C
10x09
20x80
10x09
20x00
10x08
20x80
10x08
20x00
PORTAbits.RA2
//ensure CS is negated
//send erase/write enable
//enable SSP perpiheral
Hardware Peripheral Library
//test for busy/ready
//read single byte (address)
//erase entire array
//disable SSP peripheral
apRNOVS^-page 39

Related parts for SW006010