专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
【请教】G2231的DCO能否设置成8M or 16M
2019-03-24 15:26
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
TI MCU
5600
13
1450
在例程中看到
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ;
可投文件中为何没有
CALBC1_8MHZ & CALDCO_8MHZ?
还请教如何设置~
[
本帖最后由 mavericklx 于 2011-10-16 13:13 编辑
] 此帖出自
小平头技术问答
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
13条回答
lyzhangxiang
2019-03-25 18:41
#include "msp430x20x1.h"
#define DELTA_1MHZ 244 // 244 x 4096Hz = 999.4Hz#define DELTA_8MHZ 1953 // 1953 x 4096Hz = 7.99MHz#define DELTA_12MHZ 2930 // 2930 x 4096Hz = 12.00MHz#define DELTA_16MHZ 3906 // 3906 x 4096Hz = 15.99MHz
unsigned char CAL_DATA[8]; volatile unsigned int i;int j;char *Flash_ptrA; void Set_DCO(unsigned int Delta);
void main(void){ WDTCTL = WDTPW + WDTHOLD; for (i = 0; i < 0xfffe; i++); P1OUT = 0x00; P1SEL = 0x10; P1DIR = 0x11;
j = 0;
Set_DCO(DELTA_16MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_12MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_8MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_1MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Flash_ptrA = (char *)0x10C0; FCTL2 = FWKEY + FSSEL0 + FN1; FCTL1 = FWKEY + ERASE; FCTL3 = FWKEY + LOCKA; *Flash_ptrA = 0x00; FCTL1 = FWKEY + WRT; Flash_ptrA = (char *)0x10F8; for (j = 0; j < 8; j++) *Flash_ptrA++ = CAL_DATA[j]; // re-flash DCO calibration data FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
while (1) { P1OUT ^= 0x01; for (i = 0; i < 0x4000; i++); }}
void Set_DCO(unsigned int Delta) { unsigned int Compare, Oldcapture = 0;
BCSCTL1 |= DIVA_3; TACCTL0 = CM_1 + CCIS_1 + CAP; TACTL = TASSEL_2 + MC_2 + TACLR;
while (1) { while (!(CCIFG & TACCTL0)); TACCTL0 &= ~CCIFG; Compare = TACCR0; Compare = Compare - Oldcapture; Oldcapture = TACCR0;
if (Delta == Compare) break; else if (Delta < Compare) { DCOCTL--; if (DCOCTL == 0xFF) if (BCSCTL1 & 0x0f) BCSCTL1--; } else { DCOCTL++; if (DCOCTL == 0x00) if ((BCSCTL1 & 0x0f) != 0x0f) BCSCTL1++; } } TACCTL0 = 0; TACTL = 0; BCSCTL1 &= ~DIVA_3; }
全部代码。
加载中...
查看其它13个回答
一周热门
更多
>
相关问题
相关文章
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#define DELTA_1MHZ 244 // 244 x 4096Hz = 999.4Hz#define DELTA_8MHZ 1953 // 1953 x 4096Hz = 7.99MHz#define DELTA_12MHZ 2930 // 2930 x 4096Hz = 12.00MHz#define DELTA_16MHZ 3906 // 3906 x 4096Hz = 15.99MHz
unsigned char CAL_DATA[8]; volatile unsigned int i;int j;char *Flash_ptrA; void Set_DCO(unsigned int Delta);
void main(void){ WDTCTL = WDTPW + WDTHOLD; for (i = 0; i < 0xfffe; i++); P1OUT = 0x00; P1SEL = 0x10; P1DIR = 0x11;
j = 0;
Set_DCO(DELTA_16MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_12MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_8MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Set_DCO(DELTA_1MHZ); CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1;
Flash_ptrA = (char *)0x10C0; FCTL2 = FWKEY + FSSEL0 + FN1; FCTL1 = FWKEY + ERASE; FCTL3 = FWKEY + LOCKA; *Flash_ptrA = 0x00; FCTL1 = FWKEY + WRT; Flash_ptrA = (char *)0x10F8; for (j = 0; j < 8; j++) *Flash_ptrA++ = CAL_DATA[j]; // re-flash DCO calibration data FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
while (1) { P1OUT ^= 0x01; for (i = 0; i < 0x4000; i++); }}
void Set_DCO(unsigned int Delta) { unsigned int Compare, Oldcapture = 0;
BCSCTL1 |= DIVA_3; TACCTL0 = CM_1 + CCIS_1 + CAP; TACTL = TASSEL_2 + MC_2 + TACLR;
while (1) { while (!(CCIFG & TACCTL0)); TACCTL0 &= ~CCIFG; Compare = TACCR0; Compare = Compare - Oldcapture; Oldcapture = TACCR0;
if (Delta == Compare) break; else if (Delta < Compare) { DCOCTL--; if (DCOCTL == 0xFF) if (BCSCTL1 & 0x0f) BCSCTL1--; } else { DCOCTL++; if (DCOCTL == 0x00) if ((BCSCTL1 & 0x0f) != 0x0f) BCSCTL1++; } } TACCTL0 = 0; TACTL = 0; BCSCTL1 &= ~DIVA_3; }
全部代码。
一周热门 更多>