28
6-1 hapter 6 The design of small-sca mbedded systems 1 The essence of the embedded system racteristics of the embedded system 2.1 Constituents of the embedded comput hardware and software 2.2 Timeliness 2.3 System interconnection 2.4 Reliability 2.5 The market-place

6-1 Chapter 6 The design of small-scale Embedded systems 6.1 The essence of the embedded system 6.2 Characteristics of the embedded system 6.2.1 Constituents

Embed Size (px)

Citation preview

6-1

Chapter 6 The design of small-scale Embedded systems

6.1 The essence of the embedded system

6.2 Characteristics of the embedded system

6.2.1 Constituents of the embedded computer: hardware and software 6.2.2 Timeliness 6.2.3 System interconnection 6.2.4 Reliability 6.2.5 The market-place

6-2

6.3 The skills of the embedded system designer

6-3

6.4 Microchip Inc. and PIC microcontroller It was the General Instruments Corporation, back in the late 1970s, that first produced the PIC microcontroller( Ref. 1.11) .In its early years it did not make a wide impact. The design was later taken over by Microchip Inc., and PICs are now one of the fastest moving families in the 8-bit arena, in more senses than one. First, they run very fast; second, the family is growing at a tremendous rate; and third, at the time of writing Microchip only operates with 8-bit controllers, and therefore has special interest in making this controller size as attractive as possible. PICs cover a very wide range of 8bit operation. At the lower end, they are simpler, cheaper and smaller than most devices that the competition can offer, and are thus used in situations where controller would not be thought of as the right solution, even down to simple glue logic applications. At the high end, however, they are quite ready to take on the best of the 8-bit competition, with sophisticated devices equipped with excellent peripherals. PICs have made themselves particularly attractive to the student and low-budget developer. Development tools ( both hardware and software) are cheap and readily available, and Microchip is very supportive of the novice designer.

6-4

6-5

6-6

6-7

6-8

6-9

6-10

6-11

6-12

6-13

6-14

6-15

6-16

6-17

6-18

6-19

6-20

6-21

6-22

USART 相關暫存器 USART模組也有不同的操作模式 ,但不論是哪一種操作模式 ,主要使用的包括了兩支接腳 ,RC6/TX/CK接腳與 RC7/RX/DT 接腳 , 這兩支接腳都有和其他功能多工使用 ,而使用到的暫存器主要包括了 :

• TXSTA-傳送狀態與控制暫存器

(transmit status and control register)

• RCSTA-接收狀態與控制暫存器

(receive status and control register)

• TXREG-USART傳送暫存器

(USART transmit register)

• RCREG-USART接收暫存器

(USART receive register)

• SPBRG-鲍率產生暫存器

(USART baud rate generator)

USART 泛用同步非同步接收傳輸器

(universal synchronous asynchronous receiver transmitter)

6-23

6-24

6-25

6-26

6-27

6-28

include <pic.h>#include "adc.h"Void adc_read(unsigned char channel){

ADCON0 = (channel << 3) + 0x41 // enable ADC, RC osc.ADGO = 1;while(ADGO)

continue; // wait for conversion complete}Void main(void){ unsigned char j; ADCON1=0B00000000; // CHOOSE A/D TYPE PR2=0xFF; // RESOLUTION SELECT CCPR1L=0xF0; // FREE TRISC=0; // C OUTPUT TRISB=0; // B OUTPUT TRISD=0; PORTD=0; T2CON=0x04; // set TMR2 perscale CCP1CON=0x0C; // PWM MODE for(;;) { adc_read(0); PORTB=ADRESH; // 8 BIT j=(ADRESL & 0B11000000); // 2 BIT PORTD=j; CCP1CON=(j>>2)+0x0C; // 9~10 bit CCPR1L=ADRESH; // 8 bit }}