• slider image 71
  • slider image 72
  • slider image 73
:::


Browsing this Thread:   1 Anonymous Users






SAM G55J19 Waveform 輸出請教
#1
新會員
新會員


查看用戶資訊
MCU: SAMG55J19
軟體環境: Atmel Studio 7

問題如下:
我想同時使用TIOA2、TIOB0、TIOB1、TIOB2四個來做PWM輸出控制LED
但是實際量測波形卻只有B0有波形產生,A2、B2、B1則沒有反應
想請問我的設定上有什麼地方出錯了嗎?
謝謝

/** Configure LED4 as waveform input. **/
#define LED4_CHANNEL_WAVEFORM 1
#define ID_LED4_WAVEFORM ID_TC0
#define PIN_LED4_WAVEFORM PIO_PA16_IDX
#define PIN_LED4_WAVEFORM_MUX IOPORT_MODE_MUX_B
/** Configure LED5 as waveform input. **/
#define LED56_CHANNEL_WAVEFORM 2
#define ID_LED5_WAVEFORM ID_TC0
#define PIN_LED5_WAVEFORM PIO_PA22_IDX
#define PIN_LED5_WAVEFORM_MUX IOPORT_MODE_MUX_A
/** Configure LED6 as waveform input. **/
#define ID_LED6_WAVEFORM ID_TC0
#define PIN_LED6_WAVEFORM PIO_PA21_IDX
#define PIN_LED6_WAVEFORM_MUX IOPORT_MODE_MUX_A
/** Configure LED7 as waveform input. **/
#define LED7_CHANNEL_WAVEFORM 0
#define ID_LED7_WAVEFORM ID_TC0
#define PIN_LED7_WAVEFORM PIO_PA1_IDX
#define PIN_LED7_WAVEFORM_MUX IOPORT_MODE_MUX_B

void BioLedInit_Process(void){
ioport_set_pin_mode(PIN_LED4_WAVEFORM,
PIN_LED4_WAVEFORM_MUX);
ioport_disable_pin(PIN_LED4_WAVEFORM);

ioport_set_pin_mode(PIN_LED5_WAVEFORM,
PIN_LED5_WAVEFORM_MUX);
ioport_disable_pin(PIN_LED5_WAVEFORM);

ioport_set_pin_mode(PIN_LED6_WAVEFORM,
PIN_LED6_WAVEFORM_MUX);
ioport_disable_pin(PIN_LED6_WAVEFORM);

ioport_set_pin_mode(PIN_LED7_WAVEFORM,
PIN_LED7_WAVEFORM_MUX);
ioport_disable_pin(PIN_LED7_WAVEFORM);

tcLED4567_waveform_initialize();
}

void tcLED4567_waveform_initialize(void){
uint32_t rb, rc;

sysclk_enable_peripheral_clock(ID_LED4_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED5_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED6_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED7_WAVEFORM);
pmc_disable_pck(PMC_PCK_3);
pmc_switch_pck_to_mck(PMC_PCK_3,PMC_PCK_PRES(0));
pmc_enable_pck(PMC_PCK_3);

tc_init(TC, LED4_CHANNEL_WAVEFORM,
TC_CMR_TCCLKS_TIMER_CLOCK4
|TC_CMR_WAVE
|TC_CMR_BCPB_SET
|TC_CMR_BCPC_CLEAR
|TC_CMR_CPCTRG
|TC_CMR_EEVT_XC0
);

tc_init(TC, LED56_CHANNEL_WAVEFORM,
TC_CMR_TCCLKS_TIMER_CLOCK4
|TC_CMR_WAVE
|TC_CMR_ACPA_SET
|TC_CMR_ACPC_CLEAR
|TC_CMR_BCPB_SET
|TC_CMR_BCPC_CLEAR
|TC_CMR_CPCTRG
|TC_CMR_EEVT_XC2
);

tc_init(TC, LED7_CHANNEL_WAVEFORM,
TC_CMR_TCCLKS_TIMER_CLOCK4
|TC_CMR_WAVE
|TC_CMR_BCPB_SET
|TC_CMR_BCPC_CLEAR
|TC_CMR_CPCTRG
|TC_CMR_EEVT_XC0
);

rc = BioED_Freq;
tc_write_rc(TC, LED4_CHANNEL_WAVEFORM, rc);
tc_write_rc(TC, LED56_CHANNEL_WAVEFORM, rc);
tc_write_rc(TC, LED7_CHANNEL_WAVEFORM, rc);

rb = 50 * rc / 100;
tc_write_rb(TC, LED4_CHANNEL_WAVEFORM, rb);
tc_write_rb(TC, LED56_CHANNEL_WAVEFORM, rb);
tc_write_ra(TC, LED56_CHANNEL_WAVEFORM, rb);
tc_write_rb(TC, LED7_CHANNEL_WAVEFORM, rb);

tc_start(TC0, LED4_CHANNEL_WAVEFORM);
tc_start(TC0, LED56_CHANNEL_WAVEFORM);
tc_start(TC0, LED7_CHANNEL_WAVEFORM);

}

發表於: 2018/11/16 14:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM G55J19 Waveform 輸出請教
#2
管理員
管理員


查看用戶資訊
請將
#define ID_LED4_WAVEFORM ID_TC0
改為 #define ID_LED4_WAVEFORM ID_TC1

#define ID_LED5_WAVEFORM ID_TC0
#define ID_LED6_WAVEFORM ID_TC0
改為 #define ID_LED56_WAVEFORM ID_TC2

#define ID_LED7_WAVEFORM ID_TC0
如您所述是唯一正確的

然後
sysclk_enable_peripheral_clock(ID_LED4_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED5_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED6_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED7_WAVEFORM);
改為
sysclk_enable_peripheral_clock(ID_LED4_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED56_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED7_WAVEFORM);

發表於: 2018/11/22 17:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM G55J19 Waveform 輸出請教
#3
新會員
新會員


查看用戶資訊
參照:

Libra 寫道:
請將
#define ID_LED4_WAVEFORM ID_TC0
改為 #define ID_LED4_WAVEFORM ID_TC1

#define ID_LED5_WAVEFORM ID_TC0
#define ID_LED6_WAVEFORM ID_TC0
改為 #define ID_LED56_WAVEFORM ID_TC2

#define ID_LED7_WAVEFORM ID_TC0
如您所述是唯一正確的

然後
sysclk_enable_peripheral_clock(ID_LED4_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED5_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED6_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED7_WAVEFORM);
改為
sysclk_enable_peripheral_clock(ID_LED4_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED56_WAVEFORM);
sysclk_enable_peripheral_clock(ID_LED7_WAVEFORM);


感謝您的解答,
我按照您的解說修改了,目前TIOB1與TIOB0皆有正確輸出,但TIOB2與A2還是沒有輸出,也檢查過PA22與PA21腳位沒有重複設定

發表於: 2018/12/5 19:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM G55J19 Waveform 輸出請教
#4
管理員
管理員


查看用戶資訊
請參考附件代碼, 我用SAMG55 EVB測試是可以輸出波形的
請rename為 *.7z 再解壓縮

Attach file:


Link only for registered users

發表於: 2018/12/6 14:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]