Problem in interfacing MAX6902 RTC with PIC16f873a via SPI

Status
Not open for further replies.

ajumt

Newbie level 1
Joined
Mar 17, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
kerala
Activity points
1,289
I am trying to create a large digital clock, but i am stuck at the first step itself. I am trying to communicate with MAX 6902 RTC through SPI From my PIC. Currently I am simulating in proteus, firmware is in hitech c. Program is not looks good because i altered it many ways while trying to solve it.
Here is the code.
Code:
#include <htc.h>
#include "LM016L.h"
#include "SPI.h"
#include "MAX6902.h"
#include <stdio.h>

char *myStr = "SPI CONTROL WORD - ";
//unsigned char spi_data=0;
int main(void) {
	unsigned char spi_ctrl=30;
	int flag =0;
	LCD_Init();
	LCD_Cmd(_LCD_CURSOR_OFF);
	LCD_Cmd(_LCD_CLEAR);
	LCD_Cmd(_LCD_CLEAR);
	LCD_Out(1,1,myStr);
	LCD_Out(2,1,myStr);
	//__delay_ms(6000);
	spi_Init();
	SPI_CS=0;
	int data[5];
	__delay_us(1);
	while(1) {
		do{
			flag = 0;
			WCOL=0;
			SSPBUF=BURST_READ;
			flag=1;
		}while(WCOL!=1 && flag==0);
		for (int i=0; i<5;i++){
		while(BF==0);
			data[i]=SSPBUF;
		}
		
	}
}
while debugging proteus simulation log shows that data is sent, and max6902 responding but not sending the data fully.

SPI debugger shows like this

My circuit is simple an extra connection to an lcd other than max6902

Any help will be appreciated, thanks in advance....
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…