PIC Vietnam

Go Back   PIC Vietnam > Truyền thông > Giao tiếp cổng COM và LPT

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

Giao tiếp cổng COM và LPT RS232, RS485 và LPT là những giao tiếp cơ bản và kinh điển khi mới học về vi điều khiển...

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 01-11-2012, 03:10 PM   #6
huydungsh
Nhập môn đệ tử
 
Tham gia ngày: Sep 2011
Bài gửi: 10
:
các anh cho em hỏi câu lệnh :
output_high(PIN_C0); //motor direction
output_high(PIN_C3); //brake
trong chương trình sau để làm gì ak!
//file name: using_rs232.c
//using RS232 to get value from A/D converter
//pins connections
// A0: Analog input (from 10K variable resistor)
#include <16f877.h>
#device PIC16F877 *=16 ADC=10 //using 10 bit A/D converter
#use delay(clock=20000000) //we're using a 20 MHz crystal
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7)
int16 value;
void AD_Init() //initialize A/D converter
{
setup_adc_ports(RA0_RA1_RA3_ANALOG); //set analog input ports: A0,A1,A3
setup_adc(ADC_CLOCK_INTERNAL); //using internal clock
set_adc_channel(0); //input Analog at pin A0
delay_us(10); //sample hold time
}
void main()
{
AD_Init(); //initialize A/D converter
while(1)
{
output_high(PIN_C0); //motor direction
output_high(PIN_C3); //brake
value=read_adc(); //for changing motor speed
printf("A/D value %lu\r", value);
}
}
em thấy trong sơ đồ mạch thì chân RC0,RC3 bỏ trống mà
còn chân RC6,RC7 thì lại được nối với J. sơ đồ mạch như sau:
http://img15.imageshack.us/img15/9497/16f877.png
huydungsh 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à 06:02 AM.


Đượ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