View Single Post
Old 05-09-2011, 09:25 PM   #12
phongvm90
Nhập môn đệ tử
 
Tham gia ngày: Aug 2011
Bài gửi: 5
:
anh chủ thớt ơi, mấy image của anh bị die rồi ạ.

Em muốn hỏi một chút ạ, em dùng mẫu của ccs để code cho cái usb to rs232. Nhưng khi cắm vào thì máy tính thì không có gì xảy ra cả, máy tính ko hỏi driver, pic cũng ko chạy. Em kiểm tra thì mạch vẫn có điện chạy tốt

Em dùng máy win7 64 bits ạ. Cái proteus thì ko dùng đc vì driver usb ảo của proteus ko chạy trên 64 bit nên em chỉ có cách làm mạch rồi test. Giờ nản quá...

Code em đây ạ:

#include <18F4550.h>
#device adc=8
#include <usb_cdc.h>

#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES MCLR //Master Clear pin enabled
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL5 //Divide By 12(48MHz oscillator input)
#FUSES CPUDIV4 //System Clock by 4
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES VREGEN //USB voltage regulator enabled
#FUSES ICPRT //ICPRT enabled
#FUSES HS

#use delay(clock=20000000)


void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
char c;
// init usb port to rs232
usb_cdc_init();
usb_init();
// Test interface:
// Test USB
output_low(PIN_D0);
while (TRUE)
{
usb_task();
//usb_debug_task();
if (usb_cdc_kbhit())
{
c=usb_cdc_getc();
output_toggle(PIN_D1);
}
}
phongvm90 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn