- UID
- 800417
|
本帖最后由 zerodio 于 2009-10-6 17:53 编辑
我最近在用M9S12XF512的IC做PWM輸出波形 可是不知道為何出來訊號只有直流電和5V的信號 我不知道我設定問題出錯在哪 我適用軟體產生波行的方式去做 可是波行無法出來 有各位高手知道我問題出在哪嘛?
(這禮拜要把東西做出來 不知道我問題出在哪 請各位幫幫忙 拜託)
(所有DATASHEEET我已經寫好了 暫存器可以存入 可是就是無法出現波型)
請各位高手拜託幫忙
/********************************************************/
#include "M9S12XF512.h" /* derivative information */
#include <hidef.h> /* common defines and macros */
/** Variable types and common definitions */
#include "typedefs.h"
/** CPU definitions */
#include "Cpu.h"
/** Macro definitions for general purpose I/O handling */
#include "GPIO_macros.h"
UINT16 AD_wData1;
UINT16 AD_wData2;
UINT16 AD_wData3;
UINT8 AD_wDataH;
void main(void) {
int i;
/* put your own code here */
EnableInterrupts;
/* please make sure that you never leave this function */
vfnClock_Settings();
vfnPeripheral_Settings();
/**************************************************************/
/* AD控制暫存器1: AD解析度8位元 */
ATDCTL1 = 0x00;
/* AD控制暫存器2: 啟動AD快速轉換|AD等待模式下轉換 */
ATDCTL2 = (ATDCTL2_AFFC_MASK|ATDCTL2_ICLKSTP_MASK);
/* AD控制暫存器3: 右對齊|轉換序列長度為3 */
ATDCTL3 = (ATDCTL3_DJM|ATDCTL3_S2C_MASK|ATDCTL3_S1C_MASK);
/* AD控制暫存器4:AD時脈週期為4個系統時脈|分頻係數為19 */
ATDCTL4 = (ATDCTL4_PRS4_MASK|ATDCTL4_PRS1_MASK|ATDCTL4_PRS0_MASK);
/* AD控制暫存器5:連續採集||通道AD5開始 */
ATDCTL5 = (ATDCTL5_SCAN_MASK|ATDCTL5_CC_MASK|ATDCTL5_CB_MASK);
/* AD中斷致能暫存器:禁止所有通道數字輸入緩衝 */
ATDDIEN = 0x00;
PMFCFG0 = 0x01;
PMFCFG1 = 0x81;
PMFCFG2 = 0x01;
PMFCFG3 = 0x00;
PMFOUTC = 0x01; //PWM0 bit can be controled by software
PMFOUTB = 0x01; //PWM0 active
PMFCCTL = 0x00;
PMFVAL0H = 0x10; //PWM period clock
PMFVAL0L = 0x10; //PWM period clock
PMFVAL1H = 0x10; //PWM period clock
PMFVAL1L = 0x10; //PWM period clock
PMFENCA = 0x02; //Load new prescaler A
PMFFQCA = 0x07; //PWM Frequency mode = Fbus/8
PMFMODAH = 0x01; //PWM period clock
PMFMODAL = 0xF6; //PWM period clock
for(;;){
//LED_TOGGLE(D29);/* 用于指示AD中?函?是否?行 */
LED_TOGGLE(D23);
//LED_TOGGLE(D24);
//LED_TOGGLE(D25);
//AD_wData1 = ATDDR0;/* 采集 */
//AD_wData2 = ATDDR1;/* 采集 */
//AD_wData3 = ATDDR2;/* 采集 */
AD_wDataH = ATDDR0H;
PTT = AD_wDataH ;/* ?端口B?出采集的值的高8位用于查看 */
//PT1AD_PT1AD0 = AD_wDataH & 0x01;
//PT1AD_PT1AD1 = AD_wDataH & 0x02;
//PT1AD_PT1AD2 = AD_wDataH & 0x04;
//PT1AD_PT1AD3 = AD_wDataH & 0x08;
if (ATDSTAT0_SCF!=0){
//LED_ON(D28);
} /* wait forever */
}
}
/********************************************************/ |
|