六、详细设计之硬件篇
硬件上比较简单的,我一步一步讲,不仅讲我是怎么做的,还要讲我为什么要这么做。
6.1、MCU部分
使用ATMEGA64单片机,此单片机资源还是比较丰富的。从收据手册上摘录一段如下:
Features
• High-performance, Low-power AVR® 8-bit Microcontroller
• Advanced RISC Architecture
– 130 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers + Peripheral Control Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
• Non-volatile Program and Data Memories
– 64K Bytes of In-System Reprogrammable Flash
Endurance: 10,000 Write/Erase Cycles
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– 2K Bytes EEPROM
Endurance: 100,000 Write/Erase Cycles
– 4K Bytes Internal SRAM
– Up to 64K Bytes Optional External Memory Space
– Programming Lock for Software Security
– SPI Interface for In-System Programming
• JTAG (IEEE std. 1149.1 Compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– Two Expanded 16-bit Timer/Counters with Separate Prescaler, Compare Mode, and
Capture Mode
– Real Time Counter with Separate Oscillator
– Two 8-bit PWM Channels
– 6 PWM Channels with Programmable Resolution from 1 to 16 Bits
– 8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels
2 Differential Channels with Programmable Gain (1x, 10x, 200x)
– Byte-oriented Two-wire Serial Interface
– Dual Programmable Serial USARTs
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with On-chip Oscillator
– On-chip Analog Comparator
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby
– Software Selectable Clock Frequency
– ATmega103 Compatibility Mode Selected by a Fuse
– Global Pull-up Disable
• I/O and Packages
– 53 Programmable I/O Lines
– 64-lead TQFP and 64-pad MLF
• Operating Voltages
– 2.7 - 5.5V for ATmega64L
– 4.5 - 5.5V for ATmega64
• Speed Grades
– 0 - 8 MHz for ATmega64L
– 0 - 16 MHz for ATmega64
我要用到的资源主要有:
JTAG调试:便于快速的找出错误,以前公司穷买不起仿真器,所以俺都是一遍遍的下载看现象调试,很费劲,当然也总结了一套调试的方法,以后有机会再讲这个。今年自己失业后冒着挨饿的风险买了个JTAG仿真器,初次使用,用着感觉很良好,再也不用瞎子摸象了。建议新手们买一个,老手也可以买一个的,呵呵。
XRAM接口:能够扩展外部RAM,原来俺在PC上搞编程,所以鄙人喜欢大RAM大FLASH,当然这不好,成本是蹭蹭地上去了,不过用来练练软件技术也是不错的。既然要扩展,那肯定就少不了锁存器和存储芯片了。存储芯片使用的是常用的CY62256,这没什么好说的。锁存器用的是74AHC573,为什么要用这个呢?原因有二,第一,HC系列芯片速度慢,当MCU在16M时钟下运行会有问题的(其实也能用,但是手册上讲要用AHC系列,所以咱还是乖点吧~);第二,573的管脚排列比373更有规律,便于布线。另外地址线是打乱的,也是为了好布线。这部分的原理图和PCB如下: