Ir ao conteúdo
  • Cadastre-se

Dúvida-USB CDC 18f4550


jauuun

Posts recomendados

Olá, Estou desenvolvendo um projeto aqui e estou começando a mexer com USB CDC, a comunicação está funcionando e o driver instalado, e estou recebendo um carácter pela usb e enviando para serial, mas gostaria de receber dados pela serial e enviar para usb também, alguém sabe como fazer?

Obrigado

____________________________

Consegui fazer o código e testei com o proteus, mas só funcionou depois de trocar o pino do rx para o pino 19, sempre dava erro no proteus e não recebia nada.

O código é o seguinte:

main.c

#include "C:\Documents and Settings\Administrador\Desktop\funcionou\main.h"

#include <usb_cdc.h>

void conectar(){

usb_init();

usb_task();

while(!usb_cdc_connected()){}

}

void main()

{

setup_adc_ports(NO_ANALOGS|VSS_VDD);

setup_adc(ADC_OFF);

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_comparator(NC_NC_NC_NC);

setup_vref(FALSE);

//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

// TODO: USER CODE!!

conectar();

while(true){

while(usb_enumerated()){

if(usb_cdc_kbhit()){

putc(usb_cdc_getc());

}else{

if(kbhit()){

usb_cdc_putc(getc());

}

}

}

}

}

main.h

#include <18F4550.h>

#device adc=8

#FUSES NOWDT //No Watch Dog Timer

#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale

#FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled

#FUSES NOPROTECT //Code not protected from reading

#FUSES BROWNOUT //Reset when brownout detected

#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 LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)

#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 5(20MHz 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

#use delay(clock=48000000)

#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

Alguém poderia me dar uma ajuda? Quando monto o circuito não está funcionando.

Obrigado

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!