Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Proyecto Smart Watch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Leonardo Martinez Hornak
Proyecto Smart Watch
Commits
43b72f26
Commit
43b72f26
authored
4 years ago
by
Leonardo Martinez Hornak
Browse files
Options
Downloads
Patches
Plain Diff
Timer A working for 32kHz crystal
parent
ff48380a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
firmware/src/crystal.c
+11
-5
11 additions, 5 deletions
firmware/src/crystal.c
with
11 additions
and
5 deletions
firmware/src/crystal.c
+
11
−
5
View file @
43b72f26
...
...
@@ -16,17 +16,23 @@ void initCrystal(void)
//Configure LED1 as output
P1DIR
|=
LED1
;
//HFXIN - HFXOUT PJ.2 and PJ.3 pin functions
PJSEL1
=
0x0000
;
PJSEL0
=
0x0030
;
//PJSEL1 = 0x0000;
//PJSEL0 = 0x0030;
//Leo's
PJSEL1
=
0x00
;
PJSEL0
=
0x08
;
//Clock System Key Register. This unlocks CS registers
CS
->
KEY
=
CS_KEY_VAL
;
//Basic Clock System Control Register 1 HFXTCLK / HSMCLK-SMCLK Divider = 1
//ACLK sourced by LFXTL (32kHz)
CS
->
CTL1
|=
CS_CTL1_DIVHS_0
+
CS_CTL1_SELS_5
;
//Basic Clock System Control Register 2 - Use external (>8MHz - 16 MHz) crystal for HSMCLK / capacitance of 14pF
CS
->
CTL2
|=
CS_CTL2_HFXTBYPASS_OFS
+
CS_CTL2_HFXT_EN
+
CS_CTL2_HFXTFREQ_2
+
CS_CTL2_HFXTDRIVE
;
CS
->
CTL2
|=
CS_CTL2_HFXT_EN
+
CS_CTL2_HFXTFREQ_2
+
CS_CTL2_HFXTDRIVE
;
CS
->
KEY
=
0X0000FFFF
;
...
...
@@ -38,8 +44,8 @@ void initCrystal(void)
//Timer A Control Register - Capture compare interrupts are enabled
TIMER_A0
->
CCTL
[
0
]
|=
TIMER_A_CCTLN_CCIE
;
//Timer A Capture/Compare Register 0 - set as 250mS(1/f), being f the clock frequency. No prescaler.
//TACCR = 250mS / (1 /
16M
Hz) - 1. 1 is substracted because the flag is triggered one cycle later
TIMER_A0
->
CCR
[
0
]
=
3
999
;
//TACCR = 250mS / (1 /
32Mk
Hz) - 1. 1 is substracted because the flag is triggered one cycle later
TIMER_A0
->
CCR
[
0
]
=
7
999
;
__NVIC_SetPriority
(
TA0_0_IRQn
,
0
);
__NVIC_EnableIRQ
(
TA0_0_IRQn
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment