ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
23 ноября
659021 Топик полностью
MBedder, терминатор (09.03.2016 13:48, просмотров: 281) ответил imhoteb на У кого есть опыт запуска обоих внешних кварцевых резонатров в семействе ATXMEGA A, они перключаются на запуск через регистр XOSCSEL, если по раздельности запускать то все работает, проверяется легко выводом сихнроимпульса на выводы порта, а вот
На, лентяй. 1 ГЦ от RTC, работающего от часового кварца, выведен на ledport.ledpin, тактовая (32 МГц после PLL) - на PC7 .nolist .include "ATxmega128A1def.inc" .list .equ ledport = PORTE_OUT ; Output port for LED .equ ledpin = 4 ; LED pin position .equ clkpin = 7 ; CLKOUT pin position .def tmp = r16 ; Temporary register ;----------------------------------------------------------------------------------------- .macro stsi ; ; Writes an 8-bit immediate value to a 8-bit direct RAM location. ; Usage: stsi addr,value ; Uses/trashes a tmp register for operation. ; ldi tmp,@1 sts @0,tmp .endm ;----------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------- .macro outi ; ; Writes a 8-bit immediate value to an 8-bit i/o SFR. ; Usage: outi IOREG8,value. ; Uses/trashes a tmp register for operation. ; ldi tmp,@1 out @0,tmp .endm ;----------------------------------------------------------------------------------------- .cseg ; Start of Code segment reset: rcall init_ports ; Initialize ports rcall init_osc ; Initialize oscillator main: lds tmp,RTC_CNT+0 ; Dummy LSB read required for 16-bit SFR access lds tmp,RTC_CNT+1 ; Read RTC_CNTH bst tmp,6 ; Copy RTC_CNTH 2 Hz toggling bit to T bit lds tmp,ledport ; Read LED port bld tmp,ledpin ; Paste T bit to tmp.ledpin bit position sts ledport,tmp ; Copy tmp to LED port - the LED should blink at 1 Hz rate (0.5 s lit, 0.5 s dark) rjmp main ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; Oscillator initialization: ; init_osc: stsi OSC_XOSCCTRL,OSC_FRQRANGE_12TO16_gc | OSC_XOSCSEL_XTAL_16KCLK_gc ; Set up XOSC freq range and startup time stsi OSC_CTRL,OSC_XOSCEN_bm ; Enable 16 MHz quartz oscillator stsi OSC_PLLCTRL,OSC_PLLSRC_XOSC_gc | 2 ; Select XOSC as PLL source and set PLL multiplication factor to 2 (32 MIPS) xt16m_stab: lds tmp,OSC_STATUS ; Read OSC_STATUS sbrs tmp,OSC_XOSCRDY_bp ; Wait until a 16 MHz quartz oscillator is stable (optional) rjmp xt16m_stab stsi OSC_CTRL,OSC_XOSCEN_bm | OSC_PLLEN_bm ; Enable PLL PLL_stab: lds tmp,OSC_STATUS ; Read OSC_STATUS sbrs tmp,OSC_PLLRDY_bp ; Wait until a PLL is stable rjmp PLL_stab outi CPU_CCP,0xD8 ; Unprotect the CCP protected i/o register stsi CLK_CTRL,CLK_SCLKSEL_PLL_gc ; Set a PLL as a system clock source stsi RTC_CTRL,RTC_PRESCALER_DIV1_gc ; Select non-prescaled RTC clocking stsi CLK_RTCCTRL,CLK_RTCSRC_TOSC32_gc | CLK_RTCEN_bm ; Set 32,758 Hz crystal oscillator as an RTC clock source and enable RTC ret ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; Port initialization ; init_ports: stsi PORTE_DIRSET,1<<ledpin ; LED pin = output stsi PORTC_DIRSET,1<<clkpin ; CLKOUT pin = output stsi PORTCFG_CLKEVOUT,PORTCFG_CLKOUT_PC7_gc ; Route system clock to PC7 ret ;------------------------------------------------------------------------------