PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Cơ bản về vi điều khiển và PIC

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

Cơ bản về vi điều khiển và PIC Những bài hướng dẫn cơ bản nhất để làm quen với vi điều khiển PIC

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 28-01-2010, 09:48 PM   #7
chungcb86
Đệ tử 1 túi
 
chungcb86's Avatar
 
Tham gia ngày: Dec 2009
Bài gửi: 24
:
Red face

Trích:
Nguyên văn bởi meishun View Post
thanh ghi điều khiển Input/output PORT của 12F675 là TRISIO. Ko biết set_tris_a(); có tác động đến thanh ghi này hay ko??!! Tương tự cho lệnh output_a();
==> Bạn xem lại nhé
Uk` mình xem trong dataship thì đúng là điều khiển I/O PORT của 12f675 là trisio nhưng trong file "12f675.h" thì không thấy khai báo gì cả về trisio mà chỉ có Pin_Ax thôi
Đây là file trong CCS
Trích:
//////// Standard Header file for the PIC12F675 device ////////////////
#device PIC12F675
#nolist
//////// Program memory: 1024x14 Data RAM: 64 Stack: 8
//////// I/O: 6 Analog Pins: 4
//////// Data EEPROM: 128
//////// C Scratch area: 20 ID Location: 2000
//////// Oscilator Calibration Address: 90
//////// Fuses: LP,XT,HS,EC_IO,NOWDT,WDT,CPD,NOCPD,PROTECT,NOPROTE CT,NOMCLR
//////// Fuses: MCLR,PUT,NOPUT,INTRC_IO,INTRC,RC_IO,RC,BROWNOUT,NO BROWNOUT
////////
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_x_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:

#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_A5 45

////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1

#define BYTE int
#define BOOLEAN short int

#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts

////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define WDT_FROM_SLEEP 3
#define WDT_TIMEOUT 11
#define MCLR_FROM_SLEEP 19
#define MCLR_FROM_RUN 27
#define NORMAL_POWER_UP 24
#define BROWNOUT_RESTART 26


////////////////////////////////////////////////////////////////// Timer 0
// Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER_0(),
// SET_TIMER0() or SET_RTCC(),
// GET_TIMER0() or GET_RTCC()
// Constants used for SETUP_TIMER_0() are:
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48

#define RTCC_DIV_1 8
#define RTCC_DIV_2 0
#define RTCC_DIV_4 1
#define RTCC_DIV_8 2
#define RTCC_DIV_16 3
#define RTCC_DIV_32 4
#define RTCC_DIV_64 5
#define RTCC_DIV_128 6
#define RTCC_DIV_256 7


#define RTCC_8_BIT 0

// Constants used for SETUP_COUNTERS() are the above
// constants for the 1st param and the following for
// the 2nd param:

////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_18MS 8
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15

////////////////////////////////////////////////////////////////// Timer 1
// Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
// Constants used for SETUP_TIMER_1() are:
// (or (via |) together constants from each group)
#define T1_DISABLED 0
#define T1_INTERNAL 0x85
#define T1_EXTERNAL 0x87
#define T1_EXTERNAL_SYNC 0x83

#define T1_CLK_OUT 8

#define T1_DIV_BY_1 0
#define T1_DIV_BY_2 0x10
#define T1_DIV_BY_4 0x20
#define T1_DIV_BY_8 0x30

// You may Or (with |) the above with one of:
#define T1_GATE 0x40
#define T1_GATE_INVERTED 0xC0

////////////////////////////////////////////////////////////////// COMP
// Comparator Variables: C1OUT, C2OUT
// Constants used in setup_comparator() are:
#define NC_NC_NC_NC 0x0ff07
#define NC_NC 0x0ff07
#define A0_A1 0x3ff02
#define A1_VR_OUT_ON_A2 0x6fb03
#define A1_VR 0x2ff04
#define A0_A1_OUT_ON_A2 0x3fb01

//Optionally OR with the following
#define COMP_INVERT 0x10

#bit C1OUT = 0x19.6

////////////////////////////////////////////////////////////////// VREF
// Constants used in setup_vref() are:
//
#define VREF_LOW 0xa0
#define VREF_HIGH 0x80
// Or (with |) the above with a number 0-15


////////////////////////////////////////////////////////////////// ADC
// ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),
// SET_ADC_CHANNEL(), READ_ADC()
// Constants used for SETUP_ADC() are:
#define ADC_OFF 0 // ADC Off
#define ADC_CLOCK_DIV_2 0x100
#define ADC_CLOCK_DIV_4 0x40
#define ADC_CLOCK_DIV_8 0x10
#define ADC_CLOCK_DIV_16 0x50
#define ADC_CLOCK_DIV_32 0x20
#define ADC_CLOCK_DIV_64 0x60
#define ADC_CLOCK_INTERNAL 0x30 // Internal 2-6us

// Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| GP0
#define sAN1 2 //| GP1
#define sAN2 4 //| GP2
#define sAN3 8 //| GP4
#define NO_ANALOGS 0 // None
#define AN0_ANALOG 1 //!old only provided for compatibility
#define AN1_ANALOG 2 //!old only provided for compatibility
#define AN2_ANALOG 4 //!old only provided for compatibility
#define AN3_ANALOG 8 //!old only provided for compatibility
#define ALL_ANALOG 7 //!old only provided for compatibility

// The following may be OR'ed in with the above using |
#define VSS_VDD 0x0000 //| Range 0-Vdd
#define VSS_VREF 0x4000 //| Range 0-Vref


// Constants used in READ_ADC() are:
#define ADC_START_AND_READ 7 // This is the default if nothing is specified
#define ADC_START_ONLY 1
#define ADC_READ_ONLY 6



////////////////////////////////////////////////////////////////// INT
// Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
// EXT_INT_EDGE()
//
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
#define GLOBAL 0x0BC0
#define INT_RTCC 0x0B20
#define INT_EXT 0x0B10
#define INT_AD 0x8C40
#define INT_TIMER1 0x8C01
#define INT_TIMER0 0x0B20
#define INT_EEPROM 0x8C80
#define INT_COMP 0x8C08
#define INT_RA 0xFF0B08
#define INT_RA0 0x010B08
#define INT_RA1 0x020B08
#define INT_RA2 0x040B08
#define INT_RA3 0x080B08
#define INT_RA4 0x100B08
#define INT_RA5 0x200B08

#list
Mới tìm hiểu pic mong giúp đỡ
chungcb86 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 04:16 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam