Atmega328P Datasheet 15. SCRST - System Control and Reset

Started by tha, January 05, 2018, 08:19:38 AM

Previous topic - Next topic

tha

15. SCRST - System Control and Reset

15.1. Resetting the AVR
ในระหว่าง reset, I/O Registers ทั้งหมดถูกเซทไปยังค่าเริ่มต้นของมัน, และ the program สตาร์ทการปฏิบัติงานจาก the Reset Vector. คำสั่งที่วางที่ the Reset Vector ต้องเป็นคำสั่ง an Absolute Jump instruction (JMP) ไปยัง the reset handling routine สำหรับ. ถ้า the program ไม่เปิดการใช้งาน an interrupt source, the Interrupt Vectors จะไม่ถูกใช้, และ program code ปกติสามารถถูกวางที่ตำแหน่งนี้. นี่ก็เป็นกรณีถ้า the Reset Vector อยู่ในส่วนแอ็พพลิเคชันในขณะที่ the Interrupt Vectors อยู่ในส่วนบูตหรือในทางกลับกัน. The circuit diagram ใน the next section แสดง the reset logic.

The I/O ports ของ the AVR จะถูกรีเซ็ตเป็นสถานะเริ่มต้นทันทีเมื่อแหล่งสัญญาณรีเซ็ตแหล่งหนึ่ง active. นี้ไม่ต้องการใช้แหล่งสัญญาณนาฬิกาใด ๆรันให้

หลังจาก reset sources ทั้งหมดหายไป, a delay counter ถูกปลุกขึ้น, ยืดเวลา the internal reset ออกไป. นี้ยอมให้ the power ไปถึงระดับที่มั่นคงก่อนที่การทำงานปกติจะสตาร์ท. The time-out period ของ the delay counter ถูกกำหนดโดย the user ผ่านทาง the SUT and CKSEL Fuses. ทางเลือกที่แตกต่างกันสำหรับ the delay period ถูกแสดงใน the System Clock and Clock Options chapter.

ปล. program address 0x00(เริ่มต้น) เป็น reset vector ใช่หรือเปล่า เป็นคำสั่ง jump ให้ข้าม interrupt vector ไปยัง main program ใช่มัํย ชักลืมแล้ว
http://web.csulb.edu/~hill/ee346/Lectures/10%20ATmega328P%20Interrupts.pdf

tha

15.2. Reset Sources
The device นี้มีแหล่งของการ reset ดังต่อไปนี้:
• Power-on Reset. The MCU ถูกรีเซทเมื่อ the supply voltage น้อยกว่า the Power-on Reset threshold (ธรณีประตู,จุดเริ่มต้น,จุดเปลี่ยนผ่าน)(VPOT).
• External Reset. The MCU ถูกรีเซทเมื่อลอจิกต่ำ(a low level)ปรากฏบน the RESET pin เป็นเวลานานกว่า the minimum pulse length.
• Watchdog System Reset. The MCU ถูกรีเซทเมื่อ the Watchdog Timer period สิ้นสุดลงและ the Watchdog System Reset mode ถูก enabled.
• Brown-out Reset. The MCU ถูกรีเซทเมื่อ the supply voltage VCC น้อยลงกว่า the Brown-out Reset threshold (VBOT) และ the Brown-out Detector ถูก enabled.



มันมี rs flipflop ตรวจเช็คตอนท้ายอยู่ เมื่อมีสัณญาน reset เกิดขึ้น ขา S ของฟลิบฟลอบเป็น "1" ขา Q ก็เซทด้วย เกิด internal reset พอสัณญาน reset หายไป (ขา S เป็น "0") ขา Q ก็ยังเซทค้างอยู่ (internal reset ก็ยังเซทค้างอยู่) จนกระทั่ง time out ขา R ของฟลิบฟลอบเป็น "1" ขา Q จึงถูกรีเซทกลับเป็น "0" internal reset ถึงหมดไป mcu ถึงได้เริ่มต้นทำงาน อย่างนี้ถูกต้องใหม
ปล. มีอะไรทำก็ค่อยยังชั่วหน่อย ไม่งั้นก็ว่างยาวเลย  :)

tha

15.3. Power-on Reset
A Power-on Reset (POR) pulse ถูกสร้างขึ้นโดย an On-chip detection circuit. The POR จะทำงานเมื่อ VCC ต่ำกว่า the detection level. The POR circuit สามารถใช้เพื่อเริ่มต้น(ทริกค์) the start-up Reset, รวมถึงการตรวจจับความล้มเหลวของ supply voltage.

A Power-on Reset (POR) circuit ทำให้แน่ใจว่า the device ถูกรีเซทจากการ Power-on. เมื่อถึง the Power-on Reset threshold voltage จะปลุก the delay counter, ซึ่งกำหนดความนานเท่าไหร่ที่ the device ถูกเก็บไว้ใน Reset หลังจาก VCC พุ่งขึ้น. The Reset signal ถูกทำงานขึ้นอีกครั้ง, โดยปรารถจากการหน่วงเวลา, เมื่อ VCC ลดลงต่ำกว่า the detection level.





tha

15.4. External Reset
An External Reset ถูกกำเนิดขึ้นโดยสัญญานระดับต่ำ (a low level) บน the RESET pin. Reset pulses ที่ยาวนานกว่า the minimum pulse width จะกำเนิด a reset, ถึงแม้ว่า the clock ไม่ได้รันอยู่ก็ตาม. พลัสส์ที่สั้นกว่า(Shorter pulses) ไม่กะรันตีว่าจะเกิดสัญญาน a reset. เมื่อศัญญานที่เราเอามาใช้(the applied signal) ถึง the Reset Threshold Voltage (VRST) บนขอบด้านบวกของมัน, the delay counter จะสตาร์ท the MCU หลังจาก the Time-out period (tTOUT ) หมดลง. The External Reset สามารถถูก disabled โดย the RSTDISBL fuse.




tha

15.5. Brown-out Detection
The device มี an On-chip Brown-out Detection (BOD) circuit เพื่อตรวจจับ the VCC level ในระหว่างการทำงานโดยเปรียบเทียบมันกับ a fixed trigger level. The trigger level สำหรับ the BOD สามารถถูกเลือกได้โดย the BODLEVEL Fuses. The trigger level มี curve ช่วงขาขึ้นกับช่วงขาลงไม่ตรงกัน (a hysteresis) เพื่อให้แน่ใจว่ามีช่วงฟรีระหว่างขึ้นกับลง (spike free) Brown-out Detection. The hysteresis บน the detection level ควรถูกแปลความหมายเป็น VBOT+ = VBOT + VHYST/2 และ VBOT- = VBOT -VHYST/2. เมื่อ the BOD ถูก enabled, and VCC ลดลงถึงค่าที่ต่ำกว่า the trigger level (VBOT- ในรูปต่อจากนี้), the Brown-out Reset จะถูก activated โดยทันที เมื่อ VCC เพิ่มขึ้นเหนือ the trigger level (VBOT+ ในรูปต่อจากนี้), the delay counter จะสตาร์ท the MCU หลังจาก the Time-out period (tTOUT ) หมดลง

The BOD circuit จะตรวจพบเพียงการต่ำลงของ VCC ถ้า the voltage ยังคงอยู่ต่ำกว่า the trigger level เป็นเวลานานกว่า tBOD เท่านั้น


tha

15.6. Watchdog System Reset
เมื่อ the Watchdog หมดเวลาลง, จะทำให้เกิด a short reset pulse ของช่วงเวลา 1 CK cycle . ที่ขอบขาลงของพลัสนี้, the delay timer เริ่มต้นนับ the Time-out period tTOUT.



อากาศเย็นก็ไปได้ไวหน่อย  :)

tha

15.7. Internal Voltage Reference
The device มี an internal bandgap reference. reference นี้ถูกใช้สำหรับ Brown-out Detection, และมันสามารถถูกใช้เป็นอินพุทไปยัง the Analog Comparator หรือ the ADC.

15.7.1. Voltage Reference Enable Signals and Start-up Time
The voltage reference มี a start-up time ที่อาจมีผลต่อวิธีที่มันควรถูกใช้ . เพื่อประหยัดพลังงาน, the reference นี้ไม่ได้เปิดตลอด. The reference นี้ถูกเปิดในระหว่างสถานการณ์ต่อไปนี้:
1. เมื่อ the BOD ถูก enabled (โดยการโปรแกรม the BODLEVEL [2:0] Fuses).
2. เมื่อ the bandgap reference ถูกต่อไปยัง the Analog Comparator (โดยการเซท the ACBG bit ใน ACSR (ACSR.ACBG)).
3. เมื่อ the ADC ถูก enabled.
ดังนั้น, เมื่อ the BOD ไม่ถูก enabled, หลังจากการเซท ACSR.ACBG หรือเปิดใช้งาน the ADC, ผู้ใช้ต้องยอมให้ the reference ได้ start up ก่อนที่ the output จาก the Analog Comparator หรือ ADC ถูกใช้. เพื่อลดการใช้พลังงานลงในโหมด Power-Down mode, the user สามารถหลีกเลี่ยงเงื่อนไขสามประการดังกล่าวข้างต้นเพื่อให้แน่ใจว่า the reference ถูกปิดก่อนที่จะเข้าสู่โหมด Power-Down

ปล. bandgap หมายถึงอะไรนะ ชักจะลืมแล้ว   :P

tha

15.8. Watchdog Timer
ถ้า the watchdog timer ไม่ถูกต้องการใช้ใน the application, the module ควรถูก turned off. ถ้า the watchdog timer ถูก enabled, มันจะถูก enabled ใน sleep modes ทั้งหมดและดังนั้นจึงกินพลังงานเสมอ. ใน the deeper(ลึกๆนานๆ) sleep modes, นี้จะมีส่วนร่วมอย่างมากต่อ the total current consumption.
โปรดดู Watchdog System Reset เพื่อดูรายละเอียดเกี่ยวกับการกำหนดค่า the watchdog timer.

15.8.1. Features
• สัญญานนาฬิกาจาก separate(ที่แยกต่างหาก) On-chip Oscillator
• สามโหมดการทำงาน :
  – Interrupt
  – System Reset
  – Interrupt and System Reset
• Time-out period ที่สามารถเลือกได้จาก 16ms ถึง 8s
•  Hardware fuse Watchdog เป็นไปได้ที่จะออนเสมอ (WDTON) สำหรับ fail-safe mode

15.8.2. Overview
The device มี an Enhanced Watchdog Timer (WDT). The WDT คือ a timer ที่นับรอบของ a separate(ที่แยกต่างหาก) on-chip 128kHz oscillator. The WDT ให้เกิด an interrupt หรือ a system reset เมื่อการนับถึงค่าการหมดเวลาที่กำหนด. ในโหมดการทำงานปกติ, มันมีความจำเป็นที่ระบบจะใช้คำสั่ง the Watchdog Timer Reset (WDR) เพื่อรีสตาร์ท the counter ก่อนที่จะถึง the time-out value . ถ้า the system ไม่เริ่มต้นนับ the counter ใหม่, an interrupt หรือ system reset ก็จะถูกปล่อยออกมา.



ปล. เดี๋ยวจะลองทำตัวอย่าง watchdog time ดู แต่ต้องให้อธิบายแต่ละบิทเสร็ฐก่อนเพื่อความเข้าใจบิทและ library ตอนนี้ก็ลองเสริจกูเกิ้ลด้วย avr watchdog timer เพื่อหาตัวอย่างดูไปพรางๆก่อนนะ  ;)