Preciso enviar uma string utilizando a USB do 18F4550 utilizando o compilador CCS, conforme abaixo.
Porém está enviando somente os 2 primeiros caracteres, ou seja, "Te"...
Alguém saberia me informar o que pode estar errado?
Desde já, agradeço a atenção....
- Código: Selecionar todos
#include <18F4550.H>
#device ADC = 10
#use delay(clock = 48000000)
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL2,CPUDIV1,VREGEN
#include <stdlib.h>
#use fast_io(C) //Direcionamento dos pinos será manual na PORTC
#use fast_io(D) //Direcionamento dos pinos será manual na PORTD
//Tells the CCS PIC USB firmware to include HID handling code.
#DEFINE USB_HID_DEVICE TRUE
//the following defines needed for the CCS USB PIC driver to enable the TX endpoint 1
// and allocate buffer space on the peripheral
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE 8 //allocate 8 bytes in the hardware for transmission
//the following defines needed for the CCS USB PIC driver to enable the RX endpoint 1
// and allocate buffer space on the peripheral
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for OUT bulk/interrupt transfers
#define USB_EP1_RX_SIZE 8 //allocate 8 bytes in the hardware for reception
#include "pic18_usb.h" //Microchip 18Fxx5x hardware layer for usb.c
#include "usb_desc_hid.h" //USB Configuration and Device descriptors for this UBS device
#include "usb.c" //handles usb setup tokens and get descriptor reports
void usb_debug_task(void) {
static int8 last_connected;
static int8 last_enumerated;
int8 new_connected;
int8 new_enumerated;
new_connected=usb_attached();
new_enumerated=usb_enumerated();
if (new_enumerated)
OUTPUT_HIGH(PIN_D7);
else
OUTPUT_LOW(PIN_D7);
//if (new_connected && !last_connected)
//printf("\r\n\nUSB connected, waiting for enumaration...");
//if (!new_connected && last_connected)
//printf("\r\n\nUSB disconnected, waiting for connection...");
//if (new_enumerated && !last_enumerated)
//printf("\r\n\nUSB enumerated by PC/HOST");
//if (!new_enumerated && last_enumerated)
//printf("\r\n\nUSB unenumerated by PC/HOST, waiting for enumeration...");
last_connected=new_connected;
last_enumerated=new_enumerated;
}
void main(void){ //programa principal
char out_data[20];
int8 in_data[20];
int1 usb_1=0;
usb_init();
while(true) //laço principal do programa
{
usb_task();
usb_debug_task();
if (usb_enumerated())
{
if (usb_1)
{
out_data[0] = 'T';
out_data[1] = 'e';
out_data[2] = 's';
out_data[3] = 't';
out_data[4] = 'e';
usb_put_packet(1, out_data, 5, USB_DTS_TOGGLE);
usb_1=0;
}
if (usb_kbhit(1))
{
usb_gets(1,in_data,2,5);
usb_1=1;
}
}
}
}