Melanie
Ok, Ok you caught me. My pause 40 fetish is public and now I can come out of the closet
I followed your suggestions and made the changes. Below is the revised program...
TRISA = %000100 'Set RA0-RA5 Tristate Pins for port A to output (0) or input (1)
DPIN VAR PORTA.0
CPin VAR PORTA.1
Tick VAR PORTA.2
x VAR BYTE
y VAR BYTE
m1 VAR BYTE 'minutes 1's place 0-9
m10 VAR BYTE 'minutes 10's place 0-5
B1 VAR BYTE
sec VAR BYTE
RTC VAR BYTE
ADCON0=%11000000
ADCON1=%00000111
'*************************************Initiation of variables**********************************
Pause 750 'Allow LCD to power up
m1 = 0
m10 = 0
B1=0
RTC = %11010000
' I saw in one of the responses to a similar problem, someone reset, set and reset again
' the CE bit. The lines below are an attempt at doing this...
I2CWrite DPIN, CPIN, RTC, 0, 0 'Writes to seconds byte.
Pause 10
'I2CWrite DPIN, CPIN, RTC, 1, 0 'Writes to minutes byte.
'Pause 40
'I2CWrite DPIN, CPIN, RTC, 2, 1 'Writes to hours byte.
'Pause 40
'I2CWrite DPIN, CPIN, RTC, 3, 1 'Writes to day of week byte.
'Pause 40
'I2CWrite DPIN, CPIN, RTC, 4, 1 'Writes to date byte.
'Pause 40
'I2CWrite DPIN, CPIN, RTC, 5, 1 'Writes to month byte.
'Pause 40
'I2CWrite DPIN, CPIN, RTC, 6, 1 'Writes to year byte.
'Pause 40
I2CWrite DPIN, CPIN, RTC, 7, %10010000 'Writes to control byte.
Pause 10
I2CWrite DPIN, CPIN, RTC, $11, %0000110 'Test write
Pause 10
'*************************************Program***** ********************************************
loop:
IF tick = 0 Then
SerOut PORTD.2,4,[254,131] 'locate cursor 1st line position 3
Pause 40
SerOut PORTD.2,4,[" "] 'print null value on LCD
Else
SerOut PORTD.2,4,[254,131] 'locate cursor 1st line position 3
Pause 40
SerOut PORTD.2,4,[":"] 'print a colon value on LCD
sec = sec + 1
EndIF
'Debug section of program, should be deleted after program is finalized.
I2CRead PORTA.0, PORTA.1, %11010000, $11, [m1]
SerOut PORTD.2,4,[254,196] 'locate cursor
SerOut PORTD.2,4,[#m1] 'Output the minutes 10's position
B1 = m1 'BCD to ASCII conversion
IF m1>9 Then
B1=0
EndIF
SerOut PORTD.2,4,[254,132] 'locate cursor
SerOut PORTD.2,4,[#B1] 'Output
GoTo loop
End
When I run this program, I am getting the same results as before. I get a flashing colon on the screen (my digital probe confirms the clocking signal from the RTC) and I get the number 1 at position 196 and at position 132 on the LCD screen. As you can see from the program, I am attempting to write a number 6 to the RTC and then read it back and display it on the LCD. As you said, the RTC is being initialized. I like your conversion routine better than the one I came up with so I added this. I simply cannot seem to write a value then read it back. This is really strange. Any other suggestions?
Thanks for your help
Tim





Bookmarks