AnsweredAssumed Answered

Hitachi H8/3048 - Real Time Clock DS1305 communication with SPI interface

Question asked by Łukasz F on Jan 15, 2014

Hello everyone, 

I need help with my school project. What I have to do is a real time clock DS1305 communication with SPI interface on Hitachi H8/3048 (C language). I am beginner and I don't really know how to start. The best way for me to learn are code examples but I cant find many of them. Can you explain how to initialize SPI and how should the read/write functions looks like? I will be very grateful for ANY help.


I tried to make write function, should it looks like this?



#define SDO PA.DR.BIT.B0

#define CE PA.DR.BIT.B3

#define SCLK PA.DR.BIT.B4

#define SDI PA.DR.BIT.B5



void SPI_RTC_Init(void) 


CE = 0;

SCLK = 0;


void SPI_write(unsigned short data)


CE = 1;

int i = 0;



SDI = data & 1;

data = data << 1 ;

SCLK = 1;

SCLK = 0;

if(i == 15) break; i++;