Comments, suggestions, questions about this forum? Post it here! Also for test purposes or Off-Topic discussions.

USB Keyboard with 18F2550

Postby faceu » 15 Nov 2016, 11:39

I'm trying to build my own mechanical keyboard. Everyone uses Teensy as for as i can see. I wanna use PIC18F2550 instead(see datasheet here.). I'm using CCS C btw. The problem is, i can't send more than 5 bits at all. Tried to send different arrays, they collide somehow. Increasing report count from "usb_desc_keyboard.h" doesn't work. "usb_puts" function didn't work either.

When i send multiple arrays, one by one, PIC sends key characters. No problem there. But it doesn't make the same response as a regular keyboard. Normally, first type takes longer time than others. This way PIC sends characters continuously. I wanna send 64 bits together. Is that possible?

I'm using matrix method for button interactions, got no problem there.
I added code. tx_msg array size is 7. I want to increase this to 64.
Code: Select all
void usb_keyboard_task(void)
{
   static int8 tx_msg[7]={0,0,0,0,0,0,0};
   static int8 leds;

   if(!input(pin_B0))
      tx_msg[2]=0x04;
   else
      tx_msg[2]=0;

   usb_put_packet(1,tx_msg,sizeof(tx_msg),USB_DTS_TOGGLE);

   //receive NUM LOCK, CAPS LOCK, etc LED status from PC.
   //we won't do anything with it.
   if (usb_kbhit(2))
   {
      usb_get_packet(2, &leds, 1);
   }   
}

void main(void)
{   
   setup_adc_ports(NO_ANALOGS);
   set_tris_a(0b0000000);
   set_tris_b(0b11111111);
   port_b_pullups(0b11111111);   
   usb_init_cs();   

   output_high(pin_A0);

   while (TRUE)
   {       
      usb_task();
      usb_debug_task();
      if(usb_enumerated())
      {
         usb_keyboard_task();
         delay_ms(50);
      }
   }
}
faceu
 
Posts: 3
Joined: 15 Nov 2016, 11:31
Country: Australia
Has thanked: 0 time
Been thanked: 0 time

USB Keyboard with 18F2550


Sponsor
 

Re: USB Keyboard with 18F2550

Postby maxpiano » 16 Nov 2016, 11:57

If I were you I'rather use an Arduino, there is a freely available MIDI library too that makes creating MIDI tools with Arduino a breeze. i have MIDIfied an old organ pedalboard using an Arduino (developed on a Lenorado board then scaled down to use a AT-Tiny) and works like a charm.
Last edited by maxpiano on 16 Nov 2016, 11:58, edited 2 times in total.

The author maxpiano was thanked by:
Marlowes
User avatar
maxpiano
Patch Creator
 
Posts: 2522
Joined: 27 Jun 2011, 13:29
Location: Italy
Country: Italy
Has thanked: 195 times
Been thanked: 823 times
Your Nord Gear #1: Nord Stage 2


Return to Off Topic / About this Forum



Who is online

Users browsing this forum: No registered users and 2 guests