USB com pic18f4550

Software e Hardware para uC PIC

Moderadores: andre_luis, 51, guest2003, Renie

Mensagempor lucasromeiro » 10 Jun 2011 13:54

Galera, estou querendo usar HID tb!!
So que uso o ccs. alguem tem alguma dica? estou tendo problemas.
existe algum programa no pc que receba os dados que estou enviando via usb?
valeuu
lucasromeiro
Byte
 
Mensagens: 121
Registrado em: 22 Out 2009 20:32

Mensagempor vtrx » 10 Jun 2011 18:33

Existe vários programas,mas para voce usar realmente todas as funções possíveis da classe Hid,vai ter que programar o seu.
Avatar do usuário
vtrx
Dword
 
Mensagens: 2239
Registrado em: 20 Abr 2008 21:01

Mensagempor luis fernando » 21 Jun 2011 09:44

fiz um bootloader "caseiro" para HID:
http://www.mikroe.com/forum/viewtopic.php?f=97&t=27859

na parte do PC, quem tiver dificuldade só baixar o software gratuito na net: "EasyHID" ele gera codigos fonte para o PC em diversas linguagens, delphi, vb e etc..
luis fernando
Bit
 
Mensagens: 10
Registrado em: 19 Abr 2007 09:24

Ressuscitando: USB Bulk: 4550 + CCS (Exemplo: Oscope)

Mensagempor r.dallagnol » 31 Out 2011 11:58

Srs.

Estou tentando usar o exemplo OScope do CCS mas estou encontranto a seguine dificuldade:

O dispositivo não aceita o driver BulkUSBDemo.inf e permanece com "dispositivo desconhecido".

No XP, ele sequer apresenta a tela para pedir o driver e exibe como se VID/PID fossem 0x00.

Já no Seven, ele até apresenta aquela frase USB_DESC_STRING_TYPE, do usb_desc_scope.h (CCS BULK DEMO) mas também não aceita quando direcionado manualmente.

Tentei usar aquele "clean-up" da framework da uChip mas também não ajudou.

Verifiquei e os VID / PID batem, tanto no usb.c (uc) como no .inf (PC). Pode ser mais algum erro de descritores?

Poderia ser Configuração incorreta do oscilador e seus PLLs?


Segue o código alterado para meu hardware;

Código: Selecionar todos

#include <18F4550.h>
//~~~ 20MHZ OSCILLATOR CONFIGS ~~~//
  #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
  #use delay(clock=48000000)
#use rs232(baud=9600, xmit=pin_c6, rcv=pin_a4)


/////////////////////////////////////////////////////////////////////////////
//
// Include the CCS USB Libraries.  See the comments at the top of these
// files for more information
//
/////////////////////////////////////////////////////////////////////////////
#include <pic18_usb.h>         //Microchip PIC18Fxx5x hardware layer for usb.c
#include <usb_desc_scope.h>      //USB Configuration and Device descriptors for this UBS device
#include <usb.c>              //handles usb setup tokens and get descriptor reports


/////////////////////////////////////////////////////////////////////////////
//
// Configure the demonstration I/O
//
/////////////////////////////////////////////////////////////////////////////
#define LED1 PIN_D0
#define LED2 PIN_D1
#define LED3 PIN_D2
#define LED_ON(x) output_high(x)
#define LED_OFF(x) output_low(x)
#define BUTTON_PRESSED() !input(PIN_A4)
#define USB_CON_SENSE_PIN PIN_E2

/////////////////////////////////////////////////////////////////////////////
//
// usb_debug_task()
//
// When called periodically, displays debugging information over serial
// to display enumeration and connection states.  Also lights LED2 and LED3
// based upon enumeration and connection status.
//
/////////////////////////////////////////////////////////////////////////////
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_connected)
      LED_ON(LED2);
   else
      LED_OFF(LED2);

   if (new_enumerated)
      LED_ON(LED3);
   else
      LED_OFF(LED3);

   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;
}

//We will send a 512byte message to the PC.  Since the packet size is 64, this
//will be accomplished by sending 8 64byte packets and 1 0byte packet.
#DEFINE OSCDEMO_MESSAGE_SIZE 512

//a sine table is saved to ROM to simulate adc readings
#define SINE_TABLE_SIZE 256
const char sine_table[SINE_TABLE_SIZE] =
{
   127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169,
   172, 175, 178, 181, 184, 186, 189, 192, 195, 197, 200, 202, 205, 207, 210,
   212, 214, 216, 219, 221, 223, 225, 227, 229, 230, 232, 234, 236, 237, 239,
   240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 250, 251, 252, 252, 253,
   253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 252, 252, 251, 250, 250,
   249, 248, 247, 246, 245, 244, 242, 241, 240, 238, 237, 235, 234, 232, 230,
   228, 226, 224, 222, 220, 218, 216, 214, 211, 209, 207, 204, 202, 199, 197,
   194, 191, 189, 186, 183, 180, 178, 175, 172, 169, 166, 163, 160, 157, 154,
   151, 148, 145, 142, 138, 135, 132, 129, 127, 124, 121, 118, 114, 111, 108,
   105, 102, 99, 96, 93, 90, 87, 84, 81, 78, 75, 73, 70, 67, 64,
   62, 59, 56, 54, 51, 49, 46, 44, 42, 39, 37, 35, 33, 31, 29,
   27, 25, 23, 22, 20, 18, 17, 15, 14, 12, 11, 10, 9, 8, 7,
   6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
   1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 11, 12,
   13, 14, 16, 17, 19, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38,
   41, 43, 45, 48, 50, 53, 55, 58, 60, 63, 66, 69, 71, 74, 77,
   80, 83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 122, 125
};

//oscope.exe will send us a message containg two bytes.  The first byte
//is the sample_rate, or time division between ticks.  The second byte is
//the threshold, or trigger point of the scope.
unsigned int8 rxdata[2];
#define sample_rate rxdata[1]
#define threshold rxdata[0]


/////////////////////////////////////////////////////////////////////////////
//
// read_simulated_adc()
//
// Simulates reading an adc by using the sine_table[] array.  Also will
// simulate reading at faster/slower rates by using the sample_rate
// to change the speed at which we index the sine_table[] array.
//
/////////////////////////////////////////////////////////////////////////////
int8 read_simulated_adc(void)
{
   static unsigned int8 index;
   int8 ret;
   
   ret = sine_table[index];
   index += sample_rate+1;
   
   return(ret);
}

/////////////////////////////////////////////////////////////////////////////
//
// usb_scope_task()
//
// Reads an ADC value, and once it raises above the threshold read and
// sample 512 bytes and then transmit those 512 readings to the PC.
//
/////////////////////////////////////////////////////////////////////////////
void usb_scope_task(void)
{
   unsigned int8 adc;
   static unsigned int8 last_adc;
   int8 message[OSCDEMO_MESSAGE_SIZE];
   unsigned int16 i;

   adc = read_simulated_adc();

   if ((adc >= threshold)&&(last_adc <= threshold))
   {
      message[0] = adc;
      for (i=1;i<OSCDEMO_MESSAGE_SIZE;i++)
      {
         message[i] = read_simulated_adc();
      }
      usb_puts(1, message, OSCDEMO_MESSAGE_SIZE, 50);
   }
   else
   {
      last_adc = adc;
   }
}

void main(void)
{
   int1 run = 0;
   
   printf("\r\n\nCCS USB Bulk Example");
   usb_init_cs();
   printf("\r\n\n");   
   
   LED_ON(LED1);
   LED_OFF(LED2);
   LED_OFF(LED3);
   
   while (TRUE)
   {
      usb_task();
      usb_debug_task();
   
      if(usb_enumerated())
      {
         if (run)
            usb_scope_task();
   
         if (usb_kbhit(1))
         {
            usb_get_packet(1,rxdata,2);
            printf("\r\n--> Received 2 bytes: Thresh=%U Delay=%U", threshold, sample_rate);
            run = 1;
         }
      }
   }
}


Grato
Rodrigo Dall Agnol
Projetista / Desenvolvedor
r.dallagnol
Bit
 
Mensagens: 15
Registrado em: 04 Abr 2007 11:13
Localização: Cascavel / Paraná / Brasil

Mensagempor PROF.PARDAL » 09 Nov 2011 20:15

Em primeiro lugar, uma vez que um gestor de arranque acabado (boot loader o meu # 2) para experimentar. Todos os detalhes seguem abaixo.
Este é um gerenciador de inicialização USB, que é baseado no boot loader Miocrochip. Ele é escrito em C, e com a edição estudante do compilador C18 pode ser compilado após a caminhos de projeto foram ajustados para o seu próprio PC. Ele se encaixa no bloco de boot do PIC18F2550.
O PIC está trabalhando com um 8 MHz de cristal ou de cerâmica de 8 MHz ressonador.
O gerenciador de inicialização é ativado pelo jumper JP1 primeira (ou RE3 de MCLR / Vpp) é inserido, e então conecta o dispositivo ao barramento USB. Com o brilho do LED (em RB7) mostra o carregador de boot que ele começou.

Com a ajuda do programa Windows USBoot então, qualquer software via USB são queimados no PIC, cujo endereço de início deve ser 0x800 ( veja abaixo ). Desde que eu uso o meu próprio VID_PID que pode PICDEM FS ferramenta de demonstração USB ser usado no lugar de USBooot.

Arquivo HEX do bootloader
todo o projeto C do bootloader
Drivers com o software Windows USBoot, carregador de boot, script linker
o link para um software Linux. encontra-se aqui
PROF.PARDAL
Bit
 
Mensagens: 7
Registrado em: 02 Nov 2011 10:13

Mensagempor Wagner de Queiroz » 12 Nov 2011 11:35

Tem este projeto pronto para uso no link abaixo.

PIC18F2550 USB HID Oscilloscope
http://www.semifluid.com/?p=24


e tem testa evolucao com codigo para PIC18F4550

http://www.semifluid.com/?p=23
Seja Livre, Use Linux
Avatar do usuário
Wagner de Queiroz
Word
 
Mensagens: 872
Registrado em: 11 Out 2006 13:38
Localização: Barueri-SP

Anterior

Voltar para PIC

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x