Professional Documents
Culture Documents
93 C 46 App 2310
93 C 46 App 2310
93 C 46 App 2310
The method of communication is by bit manipulation of i/o ports to produce a clock, data output, CE and to
read data i/p. Four port lines are used and the pin assignment is as follows:-
P70 - CE,
P55 - SK,
P61 - DI,
P62 - DO.
5.0 CHK_SUM - reads and sums the first 17 locations. The summed value is
compared to the checksum value stored in location 63. If in error
a '1' is returned else a '0'. The 17 locations are summed with a
fixed seed value of 0xAA55.
Passed - void.
Return - unsigned char error flag.
7.0 STO - This calculates and writes a new checksum. Once written further
writes are disabled.
Passed - void.
Return - void.
1 of 6
Hitachi Europe Ltd. ISSUE : app023/1.0
#include "ioh8325.h"
/*-----------------------------------------------------------
Function Prototypes
-----------------------------------------------------------*/
void WREN(void);
void WRDIS(void);
void WRITE(unsigned int num,unsigned char addr);
2 of 6
Hitachi Europe Ltd. ISSUE : app023/1.0
unsigned char CHK_SUM(void);
unsigned int READ(unsigned char addr);
void Write_Delay(void);
void STO(void);
void Serial_Write_8(unsigned char Data);
void Serial_Write_16(unsigned int Data);
unsigned int Serial_Read_16(void);
/*-----------------------------------------------------------*/
void WREN(void)
/*
Routine to enable writing to the 93C46
*/
{
unsigned char x=0;
Serial_Write_8(0x30); /* EWEN instruction */
for(x=0; x<=2; x++); /* delay of 25us */
M9346_CE_CLEAR;
}
void WRDIS(void)
/*
Routine to disable writing to the 93C46
*/
{
unsigned char x=0;
*/
{
unsigned char x=0;
3 of 6
Hitachi Europe Ltd. ISSUE : app023/1.0
/*
*/
{
unsigned char x;
unsigned int num;
void Write_Delay(void)
{
unsigned int x;
for (x=0;x<2000;x++); /* 11.78ms delay */
}
void STO(void)
/*
Writes new checksum value and then disables any further writes.
*/
{
unsigned int num = 0xAA55;
unsigned char x;
4 of 6
Hitachi Europe Ltd. ISSUE : app023/1.0
Write_Delay();
M9346_CE_SET;
M9346_DI_SET;
M9346_SK_SET; /* send start bit */
for(x=0; x<=2; x++);
M9346_SK_CLEAR;
for (x=0;x<8;x++)
{
if (Data&0x80)
M9346_DI_SET;
else
M9346_DI_CLEAR;
M9346_SK_SET;
for(y=0; y<=2; y++);
M9346_SK_CLEAR;
Data*=2;
}
if (z)
M9346_DI_SET;
else
M9346_DI_CLEAR;
M9346_SK_SET;
for(y=0; y<=2; y++); /* clock high time */
M9346_SK_CLEAR;
5 of 6
Hitachi Europe Ltd. ISSUE : app023/1.0
unsigned int Data=0;
for (x=0;x<16;x++)
{
Data*=2;
return(Data);
6 of 6