am in 25041 اشتراک گذاری ارسال شده در 8 خرداد، ۱۳۹۰ In this article will discuss the use of DST-128 AVR Stamp. further discussion we need to know the specifications of the DST-128 AVR Stamp. برای مشاهده این محتوا لطفاً ثبت نام کنید یا وارد شوید. ورود یا ثبت نام dst avr stamp • 128 Kb Flash PEROM • 4Kb EEPROM • 4Kb SRAM • On Chip Analog Comparator • 8 Channel 10 bit ADC • 2 8 bit PWM • 6 PWM dengan resolusi programmable (2-16 bit) • Dual Programmable UART • SPI Interface • Programmable Watchdog dengan On Chip Oscillator • Adjustable VREF ADC • 53 bit I/O • Power On Reset dan Programmable Brown out detection • Internal Calibrated RC Oscillator After knowing the specifications of the DST-AVR Stamp, we will discuss The first application discussed is the use of timers. in each application, such as the indicator to indicate the program is running, as well as reference time for the application. And the most simple application is a digital clock. This application will make PORTC bit AVR ranging from 0 to bits 7 blinks every 2 ^n bit number, which blink on bit 0 is 0.5 ms. So if the second bit will be blinks every 2 ^ 2 or 4 * 0.5 mS then at the bit to two flashes every 2ms. timing can run correctly then the timer interrupt will be generated every Timer used for this application is the timer "1". • Normal Mode • Compare Mode • Fast PWM Mode • Phase Correct PWM Mode • Phase and frequency correct PWM Mode For this application the timer operates in normal mode where the timer will count ranging from 0-65535. Timer 1 prescaler which has several functions to dividing the crystal frequency where the frequency of this crystal will be used as a source of countdown timer. Piece of program to set the timer registers as follows: TCCR1A=0x00; TCCR1B=0x04; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 46,875 kHz // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // OC1C output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer 1 Overflow Interrupt: On TCNT1H=0xB7; TCNT1L=0x1B; // Timer/Counter 1 initialization value ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; OCR1CH=0x00; OCR1CL=0x00; // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off For more details, see the datasheet. The timer will tick every 0.5ms once and will interrupt the program (temporarily stop) and run commands contained in the interrupt service routine.Piece of program below are the commands that are carried out during the timer interrupt. ISR(TIMER1_OVF_vect) { static unsigned char i; TCNT1H=0xB7; TCNT1L=0x1B; i++; PORTC=i; if(i>255) { i=0; } } For these applications led connected to PORTC. So that every time the timer interrupt not counting from 0, the initial value of necessary charging timer. Its value is obtained from 46 875 to be converted to hexadecimal numbers B71B. Previously DDR PORTC made in order to switch the output mode display. برای مشاهده این محتوا لطفاً ثبت نام کنید یا وارد شوید. ورود یا ثبت نام moving led لینک به دیدگاه
ارسال های توصیه شده