CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with RTC on dsPIC30F6014A

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

Problem with RTC on dsPIC30F6014A
PostPosted: Wed Oct 28, 2009 4:44 am     Reply with quote

Hi

I cannot manage to run 32.768hz oscillator on SOSCI/SOSCO pins. a crystal with two 18pF caps and a 100K resistor are connected to RC13 and RC14 the same as Microchip suggestion "DS70143B-page 71" all are mounted in a well grounded dual layer PCB. But there is no 32khz signal on my scope.

Code:

void main() {
setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1);
}


Should I add any other setting? any idea ?

PCD : 4.088
DSC : 30f6014a


Last edited by Imanjl on Wed Oct 28, 2009 6:24 am; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 28, 2009 5:21 am     Reply with quote

The manual requires to set LPOSCEN in OSCON. Did you?

P.S.: I guess, setup_rtc() is intended to do it with PCD.
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Oct 28, 2009 6:23 am     Reply with quote

FvM wrote:
The manual requires to set LPOSCEN in OSCON. Did you?


For enabling LPOSCEN I added these lines, still with no hope!

Code:

#include <30F6014A.h>
#bit LPOSCEN=0x742.1

void main() {
setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1);
LPOSCEN=1;
}


FvM wrote:
I guess, setup_rtc() is intended to do it with PCD


Yes , but setup_rtc() in PCD is only dedicated to PIC24 not 30F devices.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 28, 2009 6:58 am     Reply with quote

Quote:
setup_rtc() in PCD is only dedicated to PIC24 not 30F devices
You may want to ask CCS for their suggested method. I don't know, if it they have another way, or if it's simply another PCD flaw.

This can't work, because OSCON is protected
Code:
LPOSCEN=1;


You need to perform an unlock sequence before setting OSCON.1
Code:
#asm
MOV     #0x742,W1
MOV     #0x46,W2
MOV     #0x57,W3
MOV.B   W2,[W1]
MOV.B   W3,[W1]
BSET    0x742,1
#endasm
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Oct 28, 2009 7:25 am     Reply with quote

I forgot the lock setting, but there is no need for writing direct ASM commands because LPOSCEN was already configured in code via "setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1)"

PCD C/ASM list :

Code:
.................... setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1);
00134:  CLR     104
00136:  MOV     #742,W1
00138:  MOV     #2,W0
0013A:  MOV     #46,W2
0013C:  MOV     #57,W3
0013E:  MOV     W2,[W1]
00140:  MOV     W3,[W1]
00142:  MOV     W1,W4
00144:  MOV     W0,[W4]
00146:  SETM    102
00148:  BSET.B  2CD.6
0014A:  MOV     #C002,W4
0014C:  MOV     W4,104


The problem should be somewhere else.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 28, 2009 7:36 am     Reply with quote

O.K., that's another issue. PCD intends to set the bit, but the code is rubbish. It doesn't keep the requirement in the PIC30 manual:
Quote:
Byte Write is allowed for one instruction cycle. Write the
desired value or use bit manipulation instruction.

I also wonder, if the intended value for the other OSCCON bits would be correct (if taking effect at all).

It seems to be operational in recent PCD versions, by the way. (Here V4.098)
.................... setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1);
Code:
*
057E:  CLR     104
0580:  MOV     #742,W1
0582:  MOV     #2,W4
0584:  MOV     #46,W2
0586:  MOV     #57,W3
0588:  MOV.B   W2L,[W1]
058A:  MOV.B   W3L,[W1]
058C:  MOV.B   W4L,[W1]
058E:  SETM    102
0590:  MOV     #C002,W4
0592:  MOV     W4,104
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Oct 28, 2009 7:46 am     Reply with quote

FvM wrote:
O.K., that's another issue. PCD intends to set the bit, but the code is rubbish... .


That is pretty correct, because I read LPOSCEN again from that register address (0x742).
It returns 0 for setup_timer1(T1_EXTERNAL_RTC|TMR_DIV_BY_1) but returns 1 for mentioned ASM code!

Still no clock even with enabaling LPOSCEN via ASM.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 28, 2009 7:50 am     Reply with quote

You should consider, that loading the crystal nodes with a standard oscilloscope probe possibly can stop the oscillator. But there may be another hardware issue as well. I didn't use the LF crystal oscillator and can't further help in this regard.
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Oct 28, 2009 8:00 am     Reply with quote

Actually the SOSCO pin is tied to a 74HC14 chip, I use this the clock for driving another parts of the circuit. The oscilloscope probe is connected to the output of 74HC14 so I don't think there would be a problem with the probe.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group