Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:49 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Internal RTC

     Page 2 of 4    
Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:27pm 29 Jul 2011
Copy link to clipboard 
Print this post

Hi Gerard

Forgot about that thanks for the reminder.


Heppy take not below

John


Hi John.

As regards the 5V and 3.3V connections, on the original schematic they were shown on the wrong pins - so 5V is on pin 4 and 3.3V is on pin 3.

regards

Gerard (vk3cg/vk3grs)Edited by jman 2011-07-31
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 11:47pm 29 Jul 2011
Copy link to clipboard 
Print this post

i have several maxi`s one in particular from "tctec" "sm1"
there is provision for the "RTC" but i dont know when they will publish the upgrade ..and the parts ..etc...regards sparkey

technicians do it with least resistance
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 11:54pm 29 Jul 2011
Copy link to clipboard 
Print this post

Hi Sparkey

In the SM1 circuit diagram the RTC is show.
So just get the bits and add them.

John



 
Nicko`
Newbie

Joined: 01/08/2011
Location: Australia
Posts: 1
Posted: 12:28pm 01 Aug 2011
Copy link to clipboard 
Print this post

Hi everyone
Correct me if I'm wrong jman but have you got your PCF8563 board connected to the programing header.Edited by Nicko` 2011-08-02
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:10pm 01 Aug 2011
Copy link to clipboard 
Print this post

Hi Nicko

Yes you are correct the power rails line up
I have made two small cuts to the pcb and ran some
small wires to the I2C pins

John
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 10:49pm 01 Aug 2011
Copy link to clipboard 
Print this post

jman,

I have one of these on order now. I'd tend to take the wiring to the unused pins 4 & 5 to match the EV1 board. That way the expansion pins are all still free and we have a consistent basis for mods to MMBASIC.

Just my two bits.

Rob

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 10:35am 09 Aug 2011
Copy link to clipboard 
Print this post

Hi again,I have installed my board,when I run the wr8563 it returns,
0=ok 1=nack 2=timeout

then if I run the read8563 it returns error line 1030: unknown command
I have updated the firmware to 2.5,is there something I am doing wrong?
Thanks again Martin
Heppy
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:45am 09 Aug 2011
Copy link to clipboard 
Print this post

Hi Martin

Line 1030 should be
1030 RETURN

Regards

John
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:58am 09 Aug 2011
Copy link to clipboard 
Print this post

You did modify the Maximite board ?

PCB cuts show below

And add the wires for the I2C
I added the wires the 26 pin connector
on the revised schematic it is pins 6 and 8 respectively (on the original it was pins 21 and 19 respectively)

Top of PCB


Bottom of PCB




Regards
JohnEdited by jman 2011-08-10
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 11:06am 09 Aug 2011
Copy link to clipboard 
Print this post

Hi I used the Pin 2 and 3 for Gnd and 3V on the icsp connector,and soldered 2 small wires to the 26 pin con for Sda and SCL,I only put in 2 pins on the ICSP (havent soldered the others in)
1030 RETURN is return (copied and pasted it in)so I dont understand why ,its ok with return on the wr8563
Thanks
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 12:30pm 09 Aug 2011
Copy link to clipboard 
Print this post

Hi.

You can alays try the code without the gosub - here is the code with a rewrite with no gosub commands:


read8563.bas

100 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year
200 DIM RTCbuff(255)
220 i2caddr = &h51 ' PCF8563 I2C address
250 I2CEN 100,100 ' Enable I2C
260 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2
265 I2CDIS
267 ? MM.I2C; " (0=OK 1=NACK 2=Timeout)"
270 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits
290 sec$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
295 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits
305 min$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
310 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits
320 hours$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
325 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits
340 day$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
350 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits
370 month$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
380 bcdtemp = rtcbuff(6)
400 year$ = STR$((bcdtemp \ 16) * 10 + (bcdtemp mod 16) + 2000)
440 t$ = hours$+":"+min$+":"+sec$
442 D$ = day$+"/"+month$+"/"+year$
445 TIME$ = T$
446 DATE$ = D$
450 ? "Time has been set to "; TIME$
460 ? "Date has been set to "; DATE$
500 END


wr8563.bas

600 ' Get time from time$ and date$
610 tempdec = VAL(LEFT$(TIME$, 2))
617 hours = (tempdec \ 10) * 16 + tempdec mod 10
620 tempdec = VAL(MID$(TIME$, 4, 2))
627 minutes = (tempdec \ 10) * 16 + tempdec mod 10
630 tempdec = VAL(RIGHT$(TIME$, 2))
637 seconds = (tempdec \ 10) * 16 + tempdec mod 10
640 tempdec = VAL(LEFT$(DATE$, 2))
647 day = (tempdec \ 10) * 16 + tempdec mod 10
650 tempdec = VAL(MID$(DATE$, 4, 2))
657 month = (tempdec \ 10) * 16 + tempdec mod 10
660 tempdec = (VAL(RIGHT$(DATE$, 4)) - 2000)
667 year = (tempdec \ 10) * 16 + tempdec mod 10
670 ' rtcctrl = &h10
680 rtcwday= &h1
690 ' Write Time to RTC
700 i2caddr = &h51 ' PCF8563 I2C address
710 I2CEN 100,100 ' Enable I2C
720 i2csend i2caddr, 0, 1 , &h0
725 I2CSEND i2caddr, 0, 7, seconds, minutes, hours, day, rtcwday, month, year
730 I2CDIS
770 ? MM.I2C; " (0=OK 1=NACK 2=Timeout)"
780 END



Regards

Gerard (vk3cg/vk3grs)Edited by seco61 2011-08-10

Regards

Gerard (vk3cg/vk3grs)
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 08:14pm 09 Aug 2011
Copy link to clipboard 
Print this post

Hi ,I tried it with the new code but it still error,I ran the graph program to see whats on pin 1 and 2 ,I get 3.3V on both pins,I noticed when I ran the read.bas it reset the date and time and errors on 446 invaid date,I updated the firmware again and doulble checked all my work?
Thanks again for all your help
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 08:46pm 09 Aug 2011
Copy link to clipboard 
Print this post

  heppy36 said   Hi ,I tried it with the new code but it still error,I ran the graph program to see whats on pin 1 and 2 ,I get 3.3V on both pins,I noticed when I ran the read.bas it reset the date and time and errors on 446 invaid date,I updated the firmware again and doulble checked all my work?
Thanks again for all your help


Hi.

Can you please post the output from the 2 programs. Especially the lines that contain a number followed by the "(0=OK 1=NACK 2=Timeout)" message.

The "Error 446" indicates that an invalid date string was passed to the DATE$ command. This would normally be caused by invalid values either from the RTC or because the I2C communications to the RTC did not work. Add the following line to the read8563.bas program to show what values it is attempting to use:


443 ? "Setting date to "; D$; " and time to "; T$


When you mention testing pins 1 and 2 I do not see how that relates to this situation. The I2C bus is on logical pins 12 and 13 (SDC and SCL respectively) which will be pins 6 and 8 on the I/O connector (21 and 19 on the original schematic).

The bus will only be active when the Maximite is sending data using the I2CRCV and I2CSEND commands between the I2CEN and I2CDIS commands. At other times the bus will be pulled high by the pullup resistors on these pins.

Regards

Gerard (vk3cg/vk3grs)Edited by seco61 2011-08-11

Regards

Gerard (vk3cg/vk3grs)
 
Glenn

Newbie

Joined: 14/06/2011
Location: Australia
Posts: 29
Posted: 09:53pm 09 Aug 2011
Copy link to clipboard 
Print this post

I fitted a 8563 RTC from Futurlec to my Maximite also and it wouldn't work. I found that the crystal was not oscillating. Probably not the same issue as above though as the IIC port still works without xtal. The clue was it kept returning the same time.

glenn

VK3PE
 
Glenn

Newbie

Joined: 14/06/2011
Location: Australia
Posts: 29
Posted: 09:59pm 09 Aug 2011
Copy link to clipboard 
Print this post

by the way, I drilled 4 holes in the Maximite pcb in a free area and glued in a 4 way locking header. I then use this to connect to external IIC devices. I used a piece of vero board as a drill guide.

Glenn

VK3PE
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 03:06am 10 Aug 2011
Copy link to clipboard 
Print this post

When you mention testing pins 1 and 2 I do not see how that relates to this situation. The I2C bus is on logical pins 12 and 13 (SDC and SCL respectively) which will be pins 6 and 8 on the I/O connector (21 and 19 on the original schematic).
Isn't pins 6 on the connector input 1 and pin 8 input 2
I read the I/O connector (along the top) GND,5.0V,1,2,3,4,5,6,7,8,9,10,GND
GND,3.3V,20,19,18,17,16,15,14,13,12,11,GND
Or is that what I am doing wrong?

Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 06:00am 10 Aug 2011
Copy link to clipboard 
Print this post

  heppy36 said  Isn't pins 6 on the connector input 1 and pin 8 input 2
I read the I/O connector (along the top)
GND,5.0V,1,2,3,4,5,6,7,8,9,10,GND
GND,3.3V,20,19,18,17,16,15,14,13,12,11,GND
Or is that what I am doing wrong?


Hi.

I think we may be talking at cross purposes here.

So I understand exactly what you mean, I will go through what I understand your set up to be, and also where I need you to give me some more information.

First, your description of the logical pins and their location on the 26 pin I/O connector are correct.

I understand from an earlier post that you have supplied power to the PCF8563 from pins 2 and 3 of the ICSP connector. Pin 2 would be 3.3V and pin 3 is Ground (though your earlier post mentioned them in the other order, I am sure that this is what you meant).

Now I need to understand what you mean when you mention pin 1 and pin 2 - are these pins on the PCF8563 PCB or on the Maximite? If it is on the PCF8563, I need to understand which pins match the wording on the PCF8563 PCB (ie Vcc, Gnd, SDA, SCL).

The SDA connection on the PCF8563 must go to logical pin 12 on the I/O connector (as per your description of the logical pin locations - ie bottom row, 3rd from the right) and the SCL must go to logical pin 13 on the I/O connector (as per your description of the logical pin locations - ie bottom row, 4th from the right).

And please post the output of the 2 programs - especially the complete line containing the "(0=OK 1=NACK 2=Timeout)" message (it is the number at the beginning that is important).

Regards

Gerard (vk3cg/vk3grs)

Regards

Gerard (vk3cg/vk3grs)
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 08:50am 10 Aug 2011
Copy link to clipboard 
Print this post

Hi my pins are as you state 12 and 13
the errors running the code on page 3 of the forum
I set the date and time manualy,then I run wr8563
0 (0=OK 1=NACK 2=Timeout)
error line 780: unknown command
the I run the read5863
0 (0=OK 1=NACK 2=Timeout)
error line 446: invalid date

Heppy
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 09:58am 10 Aug 2011
Copy link to clipboard 
Print this post

adding
443 ? "Setting date to "; D$; " and time to "; T$
I get on screen when running
setting date to 0/0/200 and time to 0:0:0
error 446 invalid date
Heppy
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 10:21am 10 Aug 2011
Copy link to clipboard 
Print this post

Hi.

The good news is that the return codes of zero imply that the I2C communication is working. The bad news is that the data does not appear to be getting updated.

The error on line 780 implies to me that something has not worked correctly when you have copied and pasted the code - the line should be "780 END". As it is the last line of the program the error will not cause any problems.

I have just had a look at the datasheet for the PCF8563 and can see that there was an error in the wr8563 code for sending the information to the RTC. Please power off the RTC, remove the battery for 10 seconds, replace the battery and then power on.

The following code has a fix for the code problem and has a few extra print statements to try and see what is happening. Please post the output from both programs when you have run them.


wr8563.bas

600 ' Get time from time$ and date$
605 ? "Date: "; Date$; ", Time "; Time$
610 tempdec = VAL(LEFT$(TIME$, 2))
617 hours = (tempdec \ 10) * 16 + tempdec mod 10
620 tempdec = VAL(MID$(TIME$, 4, 2))
627 minutes = (tempdec \ 10) * 16 + tempdec mod 10
630 tempdec = VAL(RIGHT$(TIME$, 2))
637 seconds = (tempdec \ 10) * 16 + tempdec mod 10
640 tempdec = VAL(LEFT$(DATE$, 2))
647 day = (tempdec \ 10) * 16 + tempdec mod 10
650 tempdec = VAL(MID$(DATE$, 4, 2))
657 month = (tempdec \ 10) * 16 + tempdec mod 10
660 tempdec = (VAL(RIGHT$(DATE$, 4)) - 2000)
667 year = (tempdec \ 10) * 16 + tempdec mod 10
670 ' rtcctrl = &h10
680 rtcwday= &h1
685 ? "sec:"; seconds; " min:"; minutes; " hour:"; hours
686 ? "rtcwday:"; rtcwday; " day:"; day; " month:"; month; " year:"; year
690 ' Write Time to RTC
700 i2caddr = &h51 ' PCF8563 I2C address
710 I2CEN 100,100 ' Enable I2C
725 I2CSEND i2caddr, 0, 8, 2, seconds, minutes, hours, day, rtcwday, month, year
730 I2CDIS
770 ? MM.I2C; " (0=OK 1=NACK 2=Timeout)"
780 END


read8563.bas

100 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year
200 DIM RTCbuff(255)
220 i2caddr = &h51 ' PCF8563 I2C address
250 I2CEN 100,100 ' Enable I2C
260 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2
265 I2CDIS
267 ? MM.I2C; " (0=OK 1=NACK 2=Timeout)"
268 ? "RTCBUFF 0:"; rtcbuff(0); " 1:"; rtcbuff(1); " 2:"; rtcbuff(2); " 3:"; rtcbuff(3)
269 ? "RTCBUFF 4:"; rtcbuff(4); " 5:"; rtcbuff(5); " 6:"; rtcbuff(6)
270 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits
290 sec$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
295 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits
305 min$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
310 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits
320 hours$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
325 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits
340 day$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
350 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits
370 month$ = STR$((bcdtemp \ 16) * 10 + bcdtemp mod 16)
380 bcdtemp = rtcbuff(6)
400 year$ = STR$((bcdtemp \ 16) * 10 + (bcdtemp mod 16) + 2000)
440 t$ = hours$ + ":" + min$ + ":" + sec$
442 D$ = day$ + "/" + month$ + "/" + year$
443 ? "Setting date to "; D$; " and time to "; T$
445 TIME$ = T$
446 DATE$ = D$
450 ? "Time has been set to "; TIME$
460 ? "Date has been set to "; DATE$
500 END




Regards

Gerard (vk3cg/vk3grs)

Regards

Gerard (vk3cg/vk3grs)
 
     Page 2 of 4    
Print this page
© JAQ Software 2024