View previous topic :: View next topic |
Author |
Message |
Imanjl
Joined: 15 Nov 2004 Posts: 42
|
Problem with RTC on dsPIC30F6014A |
Posted: Wed Oct 28, 2009 4:44 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 5:21 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 6:23 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 6:58 am |
|
|
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
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
|
|
Posted: Wed Oct 28, 2009 7:25 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 7:36 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 7:46 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 7:50 am |
|
|
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
|
|
Posted: Wed Oct 28, 2009 8:00 am |
|
|
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. |
|
|
|