And another question for Bean..reference PROPBASIC

Bean...below is some code that I use to send stuff to the "terminal" aka computer screen in the IDE , and not to my LCD. (two different BAUD rates)
The "10" is a NEWLINE and the "13" is a CARRIAGE RETURN. What is the/a control character for "HOME" aka 0,0? Is there a list of control characters, more then you list in 00.01.43?
Thank you...Denno
SEROUT 30, baud2, 13
SEROUT 30, baud2, 10
SEROUT 30, baud2, "TEMP_100 = "
valueSTR_1 = STR TEMP_100,3,5
SEROUT 30, baud2, valueSTR_1
The "10" is a NEWLINE and the "13" is a CARRIAGE RETURN. What is the/a control character for "HOME" aka 0,0? Is there a list of control characters, more then you list in 00.01.43?
Thank you...Denno
Comments
con { pst formatting } HOME = 1 CRSR_XY = 2 CRSR_LF = 3 CRSR_RT = 4 CRSR_UP = 5 CRSR_DN = 6 BELL = 7 BKSP = 8 TAB = 9 LF = 10 CLR_EOL = 11 CLR_DN = 12 CR = 13 CRSR_X = 14 CRSR_Y = 15 CLS = 16
The following code is for the basic stamp
SHIFTOUT DIO_n, Clk, LSBFIRST, [%0\1,RTCCmd\5,%10\2,Temp]
Question...how do I do that in PROPBASIC?
I keep getting the error message in PROPBASIC.."To many parameters"...aka...Error 7
Thank you...
The compiler seems to like this:
SUB WriteRTC 'Write to DS1202 RTC CS_1302 = on_ SHIFTOUT data_IO, Clock, LSBFIRST, %0\1''''''''''''''''''''''',RTCCmd\5,%10\2,Temp SHIFTOUT data_IO, Clock, LSBFIRST, RTCCmd\5 SHIFTOUT data_IO, Clock, LSBFIRST, %10\2 SHIFTOUT data_IO, Clock, LSBFIRST, Temp ''SHIFTOUT datapin, clockpin, mode, value[\bits][,speed] ''If the bits parameter is not specified, 8 bits are sent. ''mode: LSBFIRST, MSBFIRST CS_1302 = off ENDSUB
I'll see if it runs when I finish the whole program...
Thank you...
https://forums.parallax.com/discussion/164268/propbasic-i2c-what-is-the-default-speed#latest
Thank you...
Yes
What do you want to know?
Dave
Not sure if you followed the link regarding the I²C default speed? It wasn't about documentation.
Would you mind sharing you code?
Thank you..
Will have to dig it out but there is nothing clever just straight forward shiftout and shiftin
for shifting out I use-
SHIFTOUT DataIO, Clock, LSBFIRST, reg0 '(SHIFTOUT datapin,clockpin,mode,data)
and for shifting in
SHIFTIN DataIO, Clock, LSBPRE, ioByte '(SHIFTIN datapin,clockpin,mode,data)
works for me.
Show me your code and I can test it.
Dave
What are you defining as the "reg0"....? The following is the code I am trying to get things started....
' SecReg CON %00000 'register locations MinReg CON %00001 ' " HrsReg CON %00010 ' " dateReg CON %00011 ' " monthReg CON %00100 ' " dayReg CON %00101 ' " CtrlReg CON %00111 ' " BrstReg CON %11111 ' " trickReg CON %01000 ' " ______[initialize the ds1302 trickle charger]_____________________________________________________ CS_1302 = off Temp = $10 '%00010000 which = $10 in HEX...disable WRITE PROTECT.. RTCCmd = CtrlReg GOSUB WriteRTC_1 temp = $A5 ' %10100101 'enable trickle charger and select 1 resistor and 1 diode RTCCmd = TrickReg GOSUB WriteRTC_2 Temp = $80 '%10000000 which = $80 in HEX...enable write protect.. RTCCmd = CtrlReg GOSUB WriteRTC_3
You will notice that there are 3 different GOSUB's that do the same thing, but I tried it the other way, and it still did not work. Then here is the rest of the code....
DO GOSUB ReadRTCburst Pause 1000 LOOP '______[SUB ROUTINE write to the ds1302 rtc]_______________ SUB WriteRTC_1 'Write to DS1202 RTC CS_1302 = on_ ' SHIFTOUT data_IO, Clock, LSBFIRST, %0\1,RTCCmd\5,%10\2,Temp SHIFTOUT data_IO, Clock, LSBFIRST, %0\1 SHIFTOUT data_IO, Clock, LSBFIRST, RTCCmd\5 SHIFTOUT data_IO, CLOCK, LSBFIRST, %10\2 SHIFTOUT data_IO, Clock, LSBFIRST, temp ' SEROUT datapin, clockpin, mode, value[\bits][,speed] ''If the bits parameter is not specified, 8 bits are sent. ''mode: LSBFIRST, MSBFIRST CS_1302 = off ENDSUB SUB WriteRTC_2 CS_1302 = on_ ' SHIFTOUT data_IO, Clock, LSBFIRST, %0\1,RTCCmd\5,%10\2,Temp SHIFTOUT data_IO, Clock, LSBFIRST, %0\1 SHIFTOUT data_IO, Clock, LSBFIRST, RTCCmd\5 SHIFTOUT data_IO, CLOCK, LSBFIRST, %10\2 SHIFTOUT data_IO, Clock, LSBFIRST, temp ' SEROUT datapin, clockpin, mode, value[\bits][,speed] ''If the bits parameter is not specified, 8 bits are sent. ''mode: LSBFIRST, MSBFIRST CS_1302 = off ENDSUB SUB WriteRTC_3 CS_1302 = on_ ' SHIFTOUT data_IO, Clock, LSBFIRST, %0\1,RTCCmd\5,%10\2,Temp SHIFTOUT data_IO, Clock, LSBFIRST, %0\1 SHIFTOUT data_IO, Clock, LSBFIRST, RTCCmd\5 SHIFTOUT data_IO, CLOCK, LSBFIRST, %10\2 SHIFTOUT data_IO, Clock, LSBFIRST, temp ' SEROUT datapin, clockpin, mode, value[\bits][,speed] ''If the bits parameter is not specified, 8 bits are sent. ''mode: LSBFIRST, MSBFIRST CS_1302 = off ENDSUB '______[SUB ROUTINE read the ds1302 RTC]___________________ SUB ReadRTCBurst CS_1302 = on_ ' SHIFTOUT data_IO, Clock, LSBFIRST, %1\1,BrstReg\5,%10\2] SHIFTOUT data_IO, Clock, LSBFIRST, %1\1 SHIFTOUT data_IO, Clock, LSBFIRST, BrstReg\5 SHIFTOUT data_IO, CLOCK, LSBFIRST, %10\2 SHIFTIN data_IO, Clock, LSBPRE, temp '''''',Minutes,Hours,date,month,day] CS_1302 = off SEROUT 30, baud2, 16 SEROUT 30, baud2, 1 SEROUT 30, baud2, "TIME_DATE = " valueSTR_3 = STR temp, 5,5 SEROUT 30, baud2, 11 SEROUT 30, baud2, valueSTR_3 ENDSUB ENDTASK '==================================================
I'm sure it's something simple....duh?
My suspicion is that you are trying to use pbasic syntax for propbasic the two are NOT the same.
This is a test program that requires you use the serial port to both program and communicate with the prop.
Set up a terminal program -I use Tera term -
Disable it so you can program the prop
Then re-enable and watch the output.
Study the code and compare the syntax used and use and adapt the bits you need.
Its not exactly the most elegant code but it should give you a start.
dave
With trepidation this UNTESTED code is your code in PropBasic form
'OR CLOCK REGISTERS WITH $80 to make into COMMAND SecReg CON %0000_0000 'register locations MinReg CON %0000_0010 ' " HrsReg CON %0000_0100 ' " dateReg CON %0000_0110 ' " monthReg CON %0000_1000 ' " dayReg CON %0000_1010 ' " CtrlReg CON %0000_1100 ' " BrstReg CON %0000_1110 ' " trickReg CON %0001_0000 ' " '______[initialize the ds1302 trickle charger]______________ Temp=$10 '%0001_0000 which = $10 in HEX...disable WRITE PROTECT.. ' ????? I make this $00 ; think its only the msbit that's used RTCCmd = CtrlReg WriteRTC temp = $A5 ' %1010_0101 'enable trickle charger and select 1 resistor and 1 diode RTCCmd = TrickReg WriteRTC Temp = $80 '%1000__0000 which = $80 in HEX...enable write protect.. RTCCmd = CtrlReg WriteRTC ...... '______[SUB ROUTINE write to the ds1302 rtc]_____ SUB WriteRTC 'Write to DS1202 RTC OR RTCCmd $80 'This sets clock command bit-, for ram it is $C0 high CS_1302 SHIFTOUT data_IO, Clock, LSBFIRST,RTCCmd SHIFTOUT data_IO, Clock, LSBFIRST,Temp low CS_1302 ENDSUB
The code in previuos post IS tested.
Dave
PLC programmers would learn this a heck of a lot quicker than ladder logic and a fast scan for those guys is 2ms
SecReg CON %00000 'register locations MinReg CON %00001 ' " HrsReg CON %00010 ' " dateReg CON %00011 ' " monthReg CON %00100 ' " dayReg CON %00101 ' " CtrlReg CON %00111 ' " BrstReg CON %11111 ' " trickReg CON %01000 ' " '--------[VARIABLES]------------------------------- RTCCmd VAR Byte 'DS1302 command Temp VAR Byte 'tempory variable to hold high and low nibble Seconds VAR Byte 'seconds register Minutes VAR Byte 'minutes register Hours VAR Byte 'hours register date VAR Byte month VAR Byte day VAR Byte '______[SUB ROUTINE write to the ds1302 rtc]_______________ '__________________________________________________________ WriteRTC: CS_1302_1620 = on_ SHIFTOUT data_IO, Clk, LSBFIRST, [%0\1,RTCCmd\5,%10\2,Temp] CS_1302_1620 = off RETURN '______[SUB ROUTINE read the ds1302 RTC]___________________ '__________________________________________________________ ReadRTCBurst: CS_1302_1620 = on_ SHIFTOUT data_IO, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2] SHIFTIN data_IO, Clk, LSBPRE, [Seconds,Minutes,Hours,date,month,day] CS_1302_1620 = off 'DEBUG HOME, HEX date 'DEBUG HOME,DEC Hours.BIT4,DEC Hours.LOWNIB,":",DEC Minutes.HIGHNIB, ' DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB,":",DEC date.HIGHNIB,DEC date.LOWNIB, ' ":",DEC month.HIGHNIB,DEC month.LOWNIB,":",DEC day.LOWNIB RETURN
"Mon/ 1/Jan 20 0 0: 0:80 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0
0"
Any thoughts..
And thank you for your help/time.
When I run the code I sent you I get......
Data in clock ram 101 20 21 23 18 19 16 17 24 25 0 18 1 20 1 0 1 0 18 0 1 1 1 0 0 67 68 76 111 118 101 Sun/11/Oct 2020 15:40: 8 Sun/11/Oct 2020 15:40:10 Sun/11/Oct 2020 15:40:12 Sun/11/Oct 2020 15:40:14 Sun/11/Oct 2020 15:40:16 Sun/11/Oct 2020 15:40:18 Sun/11/Oct 2020 15:40:20 Sun/11/Oct 2020 15:40:22 Sun/11/Oct 2020 15:40:24 Sun/11/Oct 2020 15:40:26 Sun/11/Oct 2020 15:40:28 Sun/11/Oct 2020 15:40:30 Sun/11/Oct 2020 15:40:32 Sun/11/Oct 2020 15:40:34 Sun/11/Oct 2020 15:40:36 Sun/11/Oct 2020 15:40:38 Sun/11/Oct 2020 15:40:41 Sun/11/Oct 2020 15:40:43
Think its time to post the EXACT code you are using to produce the result you showed.
Then we'll have a handle on what is going on.
Dave
'ds1302 clock DEVICE P8X32A, XTAL1, PLL16X FREQ 80_000_000 CS1302 PIN 13 low '0 low 'sel - chip select active high DS1302 pin 5 DataIO PIN 15 input '1 input 'I/O - Performs R/W to DS1302 pin 6; 2k2 resistor i/face Clock PIN 14 low '2 low 'clk - Connects to DS1302 pin 7 ' -----[ DS1302 Constants ]------------------------------------------------------- 'A/n Address bit 'R/C ram/clock 1=ram 1RAA_AAAR 'R/W read/write 1=read 1C43_210W CWPr CON $8E ' Write Protect Register 1000_1110 WPr1 CON $80 ' Set Write Protect-write to cwpr 1000_0000 WPr0 CON $00 ' Clear Write Protec-write to cwpr 0000_0000 WrBurst CON $BE ' Write Burst Of Data 1011_1110 RdBurst CON $BF ' Read Burst Of Data 1011_1111 WrRam CON $C0 ' Write to RAM Data 1100_0000 RdRam CON $C1 ' Read from RAM Data 1100_0001 RdDate CON $87 ' Read Calendar Date - numerical 1000_0111 wrramburst con $FE rdramburst con $FF ' -----[ clock Variables ]------------------------------------------------------- 'table of hub bytes for converting to binary/bcd as required 'dtable data secs HUB byte ' Seconds mints HUB byte ' Minutes hrs HUB byte ' Hours date HUB byte ' Date (numerical) month HUB byte ' Month (numerical) day HUB byte ' Day (numerical - linked to EEPROM data Sunday =1) year HUB byte ' Year mthstr data "JanFebMarAprMayJunJulAugSepOctNovDec",0 daystr data "MonTueWedThuFriSatSun".0 datestr hub string(30) tmpstr hub string(10) strslt hub string(20) index VAR long Counter VAR long ' Loop counter Char VAR long ' Character Program_State VAR long ' Program State Reg VAR long ' Read/Write Address IoByte VAR long ' Data To/From DS1302 value VAR long adr var long stmp1 var long stmp2 var long stmp3 var long tvar1 var long tvar2 var long tvar3 var long htmp var long idx var long x var long y var long show_time sub 0 pcrlf SUB 0 sertx SUB 1 print SUB 1 pstr SUB 1 phex sub 1 RTC_In SUB 0 RTC_Out SUB 0 Read_Time SUB 0 BCD_Convert SUB 0 Write_Date_Time SUB 0 ' ====================================================================== ' PROGRAM START PROGRAM Start LMM ' ====================================================================== START: 'write decimal date to hub '#### uncomment to write new date/time 'set these values to suit new date/time ' sc,mn,hr,dt,mt,dy,yr wrbyte secs,00,36,23,29,09,02,20 'secs,mins,hrs,date,month,day,year 'convert hub date to bcd date then write back to hub bcd_convert 'write clock regs from hub in bcd format 'have to clock in 8 bytes or the data will not latch!!! HIGH CS1302 SHIFTOUT DataIO, Clock, LSBFIRST,wrBurst for adr=0 to 6 rdbyte secs(adr),stmp1 '3 'adr+1 SHIFTout DataIO, Clock, LSBFIRST, stmp1 print stmp1 next SHIFTout DataIO, Clock, LSBFIRST, 0 'eighth byte essential low CS1302 '#### uncomment to write new date/time pause 8000 'time to switch terminal software to com port pcrlf 'print ram regs 0-30 pcrlf pstr "Data in clock ram" pcrlf for x=0 to 30 iobyte=0 reg=x<<1 reg=reg or rdram rtc_in strslt=str iobyte,4 pstr strslt next pcrlf pause 2000 ' main loop printing date and time to serial at 9600bd do 'note:- hub ram clock registers ' 0 1 2 3 4 5 6 'secs,mins,hrs,date,month,day,year 'read clock regs to hub and convert to decimal from bcd 'read clock burst mode HIGH CS1302 SHIFTOUT DataIO, Clock, LSBFIRST,RdBurst for adr=0 to 6 'convert from bcd to decimal SHIFTIN DataIO, Clock, LSBPRE, tvar1 tvar2=tvar1>>4 tvar2=tvar2*10 '10's tvar1=tvar1 and $0f tvar2=tvar2 + tvar1 Wrbyte secs(adr),tvar2 'secs is first item in hub ram table. adr is index to others next low CS1302 datestr="" rdbyte secs(5),tvar1 'day dec tvar1 tvar2=tvar1<<1 tvar1=tvar1+tvar2 'times 3 to index string day 3 chars each inc tvar1 tmpstr=mid daystr,tvar1,3 'get three letter day from daystr pstr tmpstr rdbyte secs(3),tvar1 'date sertx "/" print tvar1 sertx "/" rdbyte secs(4),tvar1 dec tvar1 tvar2=tvar1<<1 tvar1=tvar1+tvar2 'times 3 inc tvar1 tmpstr=mid mthstr,tvar1,3 'month pstr tmpstr pstr " 20" rdbyte secs(6),tvar1 print tvar1 'year pstr " " rdbyte secs(2),tvar1 print tvar1 sertx ":" rdbyte secs(1),tvar1 print tvar1 sertx ":" rdbyte secs(0),tvar1 print tvar1 pause 2000 pcrlf loop '==================== SUBS ================================================ 'show time in hub registers sub show_time for x=0 to 6 rdbyte secs(x),stmp1 print stmp1 next endsub '------------------------------ sub Write_Date_Time HIGH CS1302 'Select DS1302 SHIFTOUT DataIO, clock, LSBFIRST, WrBurst 'DS1302 Burst Write GOSUB BCD_Convert for x=0 to 6 'secs, mins, hrs, date, month, day, year rdbyte secs(x),stmp1 print stmp1 SHIFTOUT DataIO, Clock, LSBFIRST,stmp1 next pcrlf LOW CS1302 ' Deselect DS1302 endsub '----------------- SUB RTC_In HIGH CS1302 ' Select DS1302 SHIFTOUT DataIO, Clock, LSBFIRST, reg SHIFTIN DataIO, Clock, LSBPRE, ioByte LOW CS1302 ' Deselect DS1302 endsub '----------------- SUB RTC_Out HIGH CS1302 ' Select DS1302 SHIFTOUT DataIO, Clock, LSBFIRST, reg SHIFTOUT DataIO, Clock, LSBFIRST, ioByte LOW CS1302 ' Deselect DS1302 endsub '------------------ sub pstr 'send serial string stmp1=__param1 do rdbyte stmp1,stmp2 if stmp2=0 then exit sertx stmp2 inc stmp1 loop endsub '---------------- sub print strslt=str __param1,2 pstr strslt endsub '------------------------ sub phex htmp=__param1 stmp1= htmp and $F0 stmp1=stmp1>>4 stmp1=stmp1+48 if stmp1>57 then stmp1=stmp1+7 endif sertx stmp1 stmp1=htmp and $0F stmp1=stmp1+48 if stmp1>57 then stmp1=stmp1+7 endif sertx stmp1 endsub '----------- sub sertx 'send serial byte SEROUT 30,T9600,__param1 endsub '--------------------------- sub pcrlf sertx 13 sertx 10 endsub '--------------------------- 'convert binary to bcd in clock data table. SUB BCD_Convert FOR index = 0 TO 6 rdbyte secs(index),value ' example value=23 char=value/10 'char=23/10=2 char=char<<4 'mov 2 to msnibble char stmp1=value/10 'stmp1=2 stmp1=stmp1*10 'stmp1=20 stmp1=value-stmp1 'stmp1=23-20=3 char=char or stmp1 'or into lsnibble char making BCD version wrbyte secs(index),char NEXT endsub '------------------------------ 'secs, mins, hrs, date, month, day, year SUB Read_Time ' DS1302 Burst Read HIGH CS1302 ' SELECT DS1302 SHIFTOUT DataIO, Clock, LSBFIRST, RdBurst SHIFTIN DataIO, Clock, LSBPRE, stmp1 'secs wrbyte secs,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'mints wrbyte mints,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'hrs wrbyte hrs,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'date wrbyte date,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'month wrbyte month,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'day wrbyte day,stmp1 SHIFTIN DataIO, Clock, LSBPRE, stmp1 'year wrbyte year,stmp1 LOW CS1302 ' Deselect DS1302 endsub '==================== END ====================
And this is the output on the Parallax Serial Terminal..and I "uncommented" the part to enter the date and time..
0543541 9 232 Data in clock ram 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80
Well its a puzzle.
It looks as though you are reading in mostly zero's so I wonder if the pins are mixed up- remember the first pin on the prop is I/O pin 0 not pin 1 (ie prop pin 1 is I/O pin 0) so pins...
CS1302 PIN 13 low '0 low 'sel - chip select active high DS1302 pin 5 DataIO PIN 15 input '1 input 'I/O - Performs R/W to DS1302 pin 6; 2k2 resistor i/face Clock PIN 14 low '2 low 'clk - Connects to DS1302 pin 7
pin 13 refers to I/O pin 13 NOT physical pin 13. and so on so
CS1302 PIN 13 low 'is physical pin 14 DataIO PIN 15 input 'is physical pin 16 Clock PIN 14 low 'is physical pin 15
on my clock board the CS pin is labelled RST !!!!!Mine is running off 3.3v with 2.2k resistor on the DAT line, left on after starting with 5v then finding 3.3v worked.
Dave
I have tried running on 5 volt and 3.3 volt. No difference. The only thing I have not done, is use a 2.2K resistor on the data line to the prop. But, that was only for the 5 volt operation of the DS1302. Must be something on my end...even when I "uncomment" the section to set time and date, there is no change...
Data in clock ram 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80 Mon/ 1/Jan 20 0 0: 0:80
Just took a look at the flip module- yep all the I/O pins are clearly labelled so that can't be it.
I wonder if when you tried it using 5v that the data line pin got damaged when the clock output a 5v signal?
Might be worth while connecting to 3.3v and try new pins.
Otherwise I'm out of ideas.
Actually the guy having trouble in the SPI thread found his I/O pin had blown- so worth a try.
Dave
Don't have a clue, what I did. But, thank you for your guidance and help. If you don't mind, I will use your program with another project..I'm building my own, programmable home heating thermostat. Yes, I know you can just buy one, but what is the fun in that...really. And I needed a time source. I have always paid attention to the temperature of different things...especially on my boat...etc..
Again, thanks
It happens- after a while you start believing in ghosts!!
Glad its sorted.
Re-inventing the wheel is great fun.. because its your wheel.
Dave
HIGH CS1302 SHIFTOUT DataIO, Clock, LSBFIRST,RdBurst PAUSE 500 for adr=0 to 6 'convert from bcd to decimal SHIFTIN DataIO, Clock, LSBPRE, tvar1 'here tvar2=tvar1>>4 'here tvar2=tvar2*10 '10's 'here tvar1=tvar1 and $0f 'here tvar2=tvar2 + tvar1 'here Wrbyte secs(adr),tvar2 'secs is first item in hub ram table. adr is index to others next low CS1302
And here...
'convert binary to bcd in clock data table. SUB BCD_Convert FOR index = 0 TO 6 rdbyte secs(index),value ' example value=23 char=value/10 'char=23/10=2 char=char<<4 'mov 2 to msnibble char "Especially here..." stmp1=value/10 'stmp1=2 stmp1=stmp1*10 'stmp1=20 stmp1=value-stmp1 'stmp1=23-20=3 char=char or stmp1 'or into lsnibble char making BCD version "and here" wrbyte secs(index),char NEXT
The thermostat has two functions...One is controlled by the time, if selected, left push buttons control time, and the other function is setting by temperature, right push buttons. If the time function is selected, the heater will come on at selected hour, unless the temperature is already above the set temperature. If the temperature function is selected, then the heater will only come on if the temperature drops below the set temperature.
I'm guessing I don't understand BCD to decimal...
Anyways, I will be designing a PCB for ExpressPCB and use the PROPMINI instead of the FLIP...
Thank you again for your time and knowledge.
Ok. BCD stands for Binary Coded Decimal. It's the way the time is stored in the clock chip. See the data sheet clip-
The time is broken down into two decimal numbers-one representing tens and the other units, the tens is stored as the most significant nibble (4 bits) and the units as the least significant nibble (4 bits) and combined to make a byte. So 32 minutes would be-
number 32 in BCD 3 2 is stored as 0011 0010 ($32 in hex, 50 in decimal) number 32 in binary is 0010_0000
(You can see that if you take the BCD and display in hexadecimal format you get what looks to be the right number- but that's just an artifact that only works for nibbles 0-9, hexadecimal goes up to F. If you find that confusing ignore it!)So since we deal in 8 bit binary units there is a need to be able to convert back and for.
'read in the register to tvar1 SHIFTIN DataIO, Clock, LSBPRE, tvar1 taking the number 32 as an example 0011_0010 'start with the tens part- shift tvar1 right 4 bits removing the units and leaving the tens part where we need it. tvar2=tvar1>>4 'tvar2 now equals 0000_0011 (3) 'now multiply the tens unit by 10 to give a binary result. tvar2=tvar2*10 'tvar2 now equals 0001_1110 (30) 'tvar1 still holds the original clock value and now we need the units so we logical AND the tvar1 with $0F (0000_1111) leaving just the units' tvar1=tvar1 and $0f 'tvar1 now equals 0000_0010 (2) now we have the tens converted and the units so all we have to do is add them together tvar2=tvar2 + tvar1 'add units and tens 0000_0010 + 0001_1110=0010_0000 (2+30=32) tvar2 contains the binary representation of the BCD value.
Phew!
I leave the other conversion as an exercise for the reader....
Dave