Exact match. Not showing close matches.
PICList
Thread
'[PIC] GSM RealTimeClock'
2005\05\26@042415
by
Francois Robbertze
|
The result of a AT+CCLK? is for example:
XX+CCLK: "21/08/18,06:39:40" (note - not the correct date/time)
Approx every 50sec I call this routine to update the Hour and Minute
register.
The result of the above string is :
0x04 in the Hour register (should be 6dec or 0x06)
0x07 in the Minute register (should be 30+9=39dec or 0x27) for 06h39
I have attached the suspect code.
Where am I going wrong?
Francois
Registers
Hours equ 0x38
Minutes equ 0x39
D1 equ 0x40
D2 equ 0x41
D3 equ 0x42
etc.
GSM_TIME_UPDATE
Hours_Update
movlw 0x30 ;Ascii value of zero
subwf D20, w ;register location for Hour-Tens
movwf Temp ;Hours Tens
movlw .0 ;If Hour tens is zero then load Hour register with zero etc.
subwf Temp, w
btfsc STATUS, Z
#movlf .0, Hours ;(macro for literal to w and then w to f)
movlw .1
subwf Temp, w
btfsc STATUS, Z
#movlf .10, Hours
movlw .2
subwf Temp, w
btfsc STATUS, Z
#movlf .20, Hours
movlw 0x30 ;convert ascii
subwf D21, w ;register location for Hour-Ones
addwf Hours, f ;Add Hour-Ones
Minute_Update
movlw 0x30
subwf D23, w
movwf Temp ;Minutes-Tens
movlw .0
subwf Temp, w
btfsc STATUS, Z
#movlf .0, Minutes
movlw .1
subwf Temp, w
btfsc STATUS, Z
#movlf .10, Minutes
movlw .2
subwf Temp, w
btfsc STATUS, Z
#movlf .20, Minutes
movlw .3
subwf Temp, w
btfsc STATUS, Z
#movlf .30, Minutes
movlw .4
subwf Temp, w
btfsc STATUS, Z
#movlf .40, Minutes
movlw .5
subwf Temp, w
btfsc STATUS, Z
#movlf .50, Minutes
movlw 0x30
subwf D24, w ;register location for Minute-Ones
addwf Minutes, f ;Add Minute-Ones
goto GSM_TIME_7
GSM_TIME_6 ;Time Not Updated
bcf TimeFlag
return
GSM_TIME_7 ;Time Updated
bsf TimeFlag
return
2005\05\26@054419
by
Jinx
Got a problem with these skips intended to go over macros but
possibly crashing into them ? If your #movlf is like my mov, it'll
be two instructions
btfsc STATUS, Z
#movlf .0, Hours ;(macro for literal to w and then w to f)
movlw .1
subwf Temp, w
btfsc STATUS, Z
#movlf .10, Hours
movlw .2
subwf Temp, w
btfsc STATUS, Z
#movlf .20, Hours
movlw 0x30 ;convert ascii
2005\05\26@062708
by
Michael Rigby-Jones
|
{Quote hidden}>-----Original Message-----
>From:
spam_OUTpiclist-bouncesTakeThisOuT
mit.edu [
.....piclist-bouncesKILLspam
@spam@mit.edu]
>Sent: 26 May 2005 09:23
>To: Microcontroller discussion list - Public.
>Subject: [PIC] GSM RealTimeClock
>
>
>The result of a AT+CCLK? is for example:
>XX+CCLK: "21/08/18,06:39:40" (note - not the correct date/time)
>
>Approx every 50sec I call this routine to update the Hour and
>Minute register.
>
>The result of the above string is :
>0x04 in the Hour register (should be 6dec or 0x06)
>0x07 in the Minute register (should be 30+9=39dec or 0x27) for 06h39
>
>I have attached the suspect code.
>
>Where am I going wrong?
movlw .0 ;If Hour tens is zero then load Hour register with zero
etc.
subwf Temp, w
btfsc STATUS, Z
#movlf .0, Hours ;(macro for literal to w and then w to f)
movlw .1
subwf Temp, w
btfsc STATUS, Z
;#movlf .10, Hours
You have fallen for a classic macro problem. Your macro expands out to
two instructions, but the btfsc will only jump the first one! If you
expand out the macro you will see the problem
movlw 0x30
subwf D20, w ; D23 could be '0','1' or '2'
movwf Temp ; Temp could be 0,1 or 2
movlw .0 ;
subwf Temp, w ; W could be 0,1 or 2
btfsc STATUS, Z ; if W is 0 skip next instruction
movlw .0
movwf Hours ; Hours could be 0,1 or 2 !!!!
Something like this might be better (untested!!!)
; get the Hour tens
movlw 0x30 ; convert ASCII to binary
subwf D20,W ; D20 holds Hours_Tens
movwf Hours ; Hours = Hour_Tens
addwf Hours,W ; W = Hour_Tens*2
addwf Hours,F ; Hours = Hour_Tens*3
addwf Hours,F ; Hours = Hour_Tens*5
movf Hours,W ; W = Hour_Tens*5
addwf Hours,F ; Hours = Hour_Tens*10
; add the Hour units
movlw 0x30
subwf D21, W ; D21 holds Hours_Units
addwf Hours,F ; Hours = Hour_Tens + Hours_Units
; get the Minute tens
movlw 0x30 ; convert ASCII to binary
subwf D23,W ; D20 holds Minutes_Tens
movwf Minutes ; Minutes = Minutes_Tens
addwf Minutes,W ; W = Minutes_Tens*2
addwf Minutes,F ; Minutes = Minutes_Tens*3
addwf Minutes,F ; Minutes = Minutes_Tens*5
movf Minutes,W ; W = Minutes_Tens*5
addwf Minutes,F ; Minutes = Minutes_Tens*10
; add the Minute units
movlw 0x30
subwf D24,W ; D24 holds Minutes_Units
addwf Minutes,F ; Minutes = Minutes_Tens + Minutes_Units
Regards
Mike
=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
2005\05\26@072326
by
Francois Robbertze
> Got a problem with these skips intended to go over macros but
> possibly crashing into them ? If your #movlf is like my mov, it'll
> be two instructions
>You have fallen for a classic macro problem. Your macro expands out to
>two instructions, but the btfsc will only jump the first one! If you
>expand out the macro you will see the problem
Thanks, that is surely my problem!
I'm so used to this macro that I used it as a extra instruction lately.
Francois
2005\05\26@081100
by
Jinx
> I'm so used to this macro that I used it as a extra instruction lately
Do you use MPLAB and its colour scheme ? Edit/Properties/Text
In my set up actual instructions are blue and macro labels are purple
so they stand out as a reminder, although I've not made the skip
mistake for a long long time anyway
2005\05\27@041722
by
Francois Robbertze
Hi Jinx,
I am still using ver 5.20.00 so i dont think it has this function.
It have a colors tab in the Options/Environment setup.(never used this)
In the edit menu there are a text menu that i can indent, uppercase etc.
Francois
{Original Message removed}
2005\05\27@043019
by
Francois Robbertze
|
Thanks Mike
Your code is now tested and it works fine. (Much better than my method -
short and sweet)
regards
Francois
{Quote hidden}> Something like this might be better (untested!!!)
>
> ; get the Hour tens
> movlw 0x30 ; convert ASCII to binary
> subwf D20,W ; D20 holds Hours_Tens
> movwf Hours ; Hours = Hour_Tens
> addwf Hours,W ; W = Hour_Tens*2
> addwf Hours,F ; Hours = Hour_Tens*3
> addwf Hours,F ; Hours = Hour_Tens*5
> movf Hours,W ; W = Hour_Tens*5
> addwf Hours,F ; Hours = Hour_Tens*10
>
> ; add the Hour units
> movlw 0x30
> subwf D21, W ; D21 holds Hours_Units
> addwf Hours,F ; Hours = Hour_Tens + Hours_Units
>
> ; get the Minute tens
> movlw 0x30 ; convert ASCII to binary
> subwf D23,W ; D20 holds Minutes_Tens
> movwf Minutes ; Minutes = Minutes_Tens
> addwf Minutes,W ; W = Minutes_Tens*2
> addwf Minutes,F ; Minutes = Minutes_Tens*3
> addwf Minutes,F ; Minutes = Minutes_Tens*5
> movf Minutes,W ; W = Minutes_Tens*5
> addwf Minutes,F ; Minutes = Minutes_Tens*10
>
> ; add the Minute units
> movlw 0x30
> subwf D24,W ; D24 holds Minutes_Units
> addwf Minutes,F ; Minutes = Minutes_Tens + Minutes_Units
>
>
>
> Regards
>
> Mike
>
2005\05\27@055327
by
Jinx
> I am still using ver 5.20.00 so i dont think it has this function.
It's worth upgrading, if you can/want to/need to, as later versions
have some other useful editing features, like bookmarks (which
I think in no versions are saved with a project - a nuisance). And
there's obviously support for newer devices and programmers etc
More... (looser matching)
- Last day of these posts
- In 2005
, 2006 only
- Today
- New search...