Yes tried new chip. Output pins are connected to MPSA42 transistor via 10K resistor.
Yes tried new chip. Output pins are connected to MPSA42 transistor via 10K resistor.
If I swap chip with 12F1840, will problem still exist?
I decided to put it aside, to give my mind some rest, and back to DS3231.
I found that it does not return seconds properly.
Have two different example codes, they work fine for minutes and hours, but does not work for seconds - seconds increase like 02 04 08 10 12 14 16 till 28, then 29 and again increase in 2 and so on.
Code:SecondsMSB=BCDSeconds & $70 SecondsMSB=SecondsMSB>>4 SecondsLSB=BCDSeconds & $0F ' Seconds=(SecondsMSB*10)+SecondsLSB 'combines DECMinutes MSB and LSB x=RTCSEC >> 4 Y=RTCseC // 16 z=X*10+Y
more than likely , you need to understand and remedy the situation.If I swap chip with 12F1840, will problem still exist?
http://www.picbasic.co.uk/forum/showthread.php?t=15843&highlight=shadow
http://www.picbasic.co.uk/forum/showthread.php?t=15013&highlight=shadow
and post your code and a schematic so we don't just keep guessing
Warning I'm not a teacher
Code is posted above.
Schematic is simple, there are 4 MPSA42 transistors, each of which is connected via 10K resistor to corresponding ports (ZERO, ONE, TWO, TRE) as shown in code. GPIO.5 is tied via 10K resistor to VDD, and button pulls it to zero.
Only addition to code above is
Code:koka: if GPIO.5=0 THEN 'if pin pressed goto tavi 'launch rotation ENDIF pause 1 GOTO KOKA
i mean post the code you are using now!and post your code and a schematic so we don't just keep guessing
i'm likely to make mistakes going back through several pages of add infested forum to try and patch together what i think you may be using.
and even a hand drawn schematic makes things clearer
Warning I'm not a teacher
OK one moment, let me finish this first, figured DS3231 error reason now, it was due to re-using variable. I need rest, serious rest![]()
Here it is:
if I change TRISIO config so port 5 is no longer input and directly launch the code, it works properly.
Code:'**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 15.05.2014 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ANSEL = %00000000 'disable analog CMCON0 = 7 'disable comparators TRISIO=%00101000 'input config OSCCON = %01110111 'Include "Modedefs.bas" Define OSC 8 ' Set Xtal Frequency ' Clk Var GPIO.5 ' Data is clocked on rising edge of this pin kviteli ' Dta Var GPIO.4 ' Bits are shifted out of this pin stafilosferi ZERO var GPIO.0 ONE VAR GPIO.4 TWO VAR GPIO.1 TRE VAR GPIO.2 cik var byte 'loop variable x var byte 'delay variable increment var byte 'incremental variable lop var byte 'also variable increment=0 'temp sub var byte 'intracounter variable sub=9 x=44 '22 x and 295 y for 30 second loop y var word 'showdelay 44 and 590 for 1 minute loop y=590 'INIT tube and reset to 0 inika: LOW ONE LOW TWO LOW TRE HIGH ZERO PAUSE x high one LOW ZERO pause x high two low one pause x high tre low two pause x high zero low tre pause x low zero koka: if GPIO.5=0 THEN goto tavi ENDIF pause 1 GOTO KOKA tavi: 'stage 1______________________________________________ sub=9 gosub sub9 high one 'proper finish? one and two pause x low one high two pause x low two high zero Pause Y'delay for display low zero sta2: 'stage 2 ______________________________________________ gosub sub9 gosub subzero Pause Y low one 'stage 3____________________________________________ gosub sub9 gosub subzero pause x high two low one Pause Y high tre low two pause x low tre 'stage 4____________________________________________ sub=8 gosub sub9 gosub subzero gosub sub2 Pause Y low tre 'stage 5____________________________________________ gosub sub9 gosub subzero gosub sub2 pause x high one low tre Pause Y low one 'stage 6____________________________________________ gosub sub9 gosub subzero gosub sub2 pause x high one low tre pause x high two low one Pause Y high tre low two 'stage 7____________________________________________ pause x low tre sub=7 gosub sub9 gosub subzero gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two Pause Y low tre 'stage 8____________________________________________ gosub sub9 gosub subzero gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre Pause Y low one 'stage 9____________________________________________ 'X=100 gosub sub9 gosub subzero gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one Pause Y high tre low two pause x 'stage 10____________________________________________ low tre sub=6 gosub sub9 gosub subzero gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one pause x high tre low two Pause Y low tre 'stage 11____________________________________________ low tre sub=6 gosub sub9 gosub subzero pause x high two low one pause x high tre low two pause x gosub sub1 high one low tre Pause Y low ONE 'stage 12____________________________________________ low tre sub=6 gosub sub9 gosub subzero pause x high two low one pause x high tre low two pause x gosub sub1 high one low tre pause x high two low ONE Pause Y low two 'stage 13____________________________________________ high tre pause x low tre sub=5 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre pause x high two low ONE pause x high tre low two Pause Y low tre 'stage 14____________________________________________ sub=5 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre pause x high two low ONE pause x high tre low two pause x high one low tre Pause Y low one 'stage 15____________________________________________ sub=5 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one Pause Y low two 'stage 16____________________________________________ high tre pause x low tre sub=4 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two Pause Y low tre 'stage 17____________________________________________ sub=4 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre Pause Y low one 'stage 18____________________________________________ sub=4 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one Pause Y low two 'stage 19____________________________________________ high tre pause x low tre sub=3 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one pause x high tre low two Pause Y low tre 'stage 20____________________________________________ sub=3 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one pause x high tre low two pause x high one low tre Pause Y low one 'stage 21____________________________________________ sub=3 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 high one low tre pause X high two low one Pause Y low two 'stage 22____________________________________________ high tre pause x low tre sub=2 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 high one low tre pause X high two low one pause x high tre low two Pause Y low tre 'stage 23____________________________________________ sub=2 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 high one low tre gosub sub2 pause X high one low tre Pause Y low one 'stage 24____________________________________________ sub=2 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 high one low tre gosub sub2 pause X high one low tre pause X high two low one Pause Y low two 'stage 25____________________________________________ high tre pause x low tre sub=1 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 high one low tre gosub sub2 pause X high one low tre pause X high two low one pause x high tre low two Pause Y low tre 'stage 26____________________________________________ sub=1 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 gosub sub1 high one low tre Pause Y low one 'stage 27____________________________________________ sub=1 gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 gosub sub1 high one low tre pause x high two low one Pause Y low two 'stage 28____________________________________________ high tre pause x low tre 'sub=1 'gosub sub9 gosub subzero gosub sub2 pause x '----- gosub sub1 '------ high one low tre gosub sub2 pause x gosub sub1 gosub sub1 high one low tre pause x high two low one pause x high tre low two Pause Y low tre 'x=400 'stage 29____________________________________________ high one pause x high two low one pause x high zero low two pause x low zero sub=9 gosub sub9 high one Pause Y low one 'x=400 'stage 30____________________________________________ high two pause x high zero low two pause x low zero sub=9 gosub sub9 high one pause x high two low one Pause Y low two 'stage 31____________________________________________ high zero pause x low zero sub=9 gosub sub9 high one 'proper finish? one and two pause x low one high two pause x low two high zero Pause Y low zero goto koka sub9 'subroutine for spinning for cik=1 to sub 'amount needed for full loop high one pause x high two low one pause x high tre low two pause x low tre next return subzero: high one 'proper finish? one and two pause x high two low one pause x high zero low two pause x'delay for display high one low zero 'subzero here return sub1: 'smaller sub high one low tre pause x high two low one pause x high tre low two pause x high one low tre pause x high two low one pause x high tre low two pause x return sub2: 'even smaller sub pause x high two low one pause x high tre low two return
the code compiles and runs flawlessly in proteus, thats not the issue , check your circuit
![]()
Warning I'm not a teacher
Bookmarks