HIDKEYS example modified with 20MHZ clock not recognize

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
reptooyep
Posts: 1
Joined: Tue Sep 04, 2018 10:52 am

HIDKEYS example modified with 20MHZ clock not recognize

Post by reptooyep » Tue Sep 04, 2018 4:19 pm

Hi everyone,
I'm playing with avrs since few years now and i'm locked on a problem.
I'm making a boat GPS keyboard to use it with oppenplotter on raspberry. The keyboard will return kbd caracters to make shortcuts in oppenplotter (- for zoom-, + for zoom+, etc..)
I have an old NAVIONICS GPS and want to put the raspberry in it and keep the existing keyboard.
My board is SMD version with 20MHZ crystal. I use the same hardware as the example, exept for the keymapping (10 keys for the keyboard and 1 for toggling kbd lights).
I've modified the example to fit my hardware :
i use 1.8kohm pullup for D- and 3.6v zener diodes on both D+ and D-

Code: Select all

#define F_CPU 20000000UL
in main.c and every h files


The new keyboard function works the same (returns 1 to 10 for each key and 0 for no key)

Code: Select all

static uchar    keyPressed(void)
{

uchar   i;
   uint8_t bits = PINC;
   if (!(bits & 1)) i=1;                  //Si un des bits est a 0 (!), i=valeurs correspondante
   if (!(bits & 2)) i= 2;
   if (!(bits & 8)) i= 3;
   if (!(bits & 16)) i= 4;
   if (!(bits & 32)) i= 5;
   if (bits & 59) i=0;                     //cas ou tout est a 1 (32+16+8+2+1), pas de touche => i=0
   bits = PINB;
   if (!(bits & 2)){
       i= 0;
      PORTC ^= (1<<PC2);                  //^= : bascule
      _delay_ms(10);                     //anti rebond (appui multiple)      
   }
   if (!(bits & 16)) i= 6;
   if (!(bits & 32)) i= 7;
   if (bits & 50) i=0;                     //cas ou tout est a 1 (32+16+2), pas de touche => i=0
   bits = PIND;
   if (!(bits & 2)) i= 8;
   if (!(bits & 32)) i= 9;
   if (!(bits & 128)) i= 10;
   if (bits & 162) i=0;                  //cas ou tout est a 1 (128+32+2), pas de touche => i=0
   return i;                           //A la fin, on retourne la valeur de la touche (0 = pas de touche et de 1 à 10 : une touche)

}


When i plug the device, windows says :"USB device not recognized etc ..."
The toggling lights works.

Is there anything else to modify in order to use 20MHZ ?
I'm thinking about the 22ms delay :

Code: Select all

        if(TIFR & (1<<TOV0)){   /* 22 ms timer */
            TIFR = 1<<TOV0;
            if(idleRate != 0){
                if(idleCounter > 4){
                    idleCounter -= 5;   /* 22 ms in units of 4 ms */



or the timer in hardwareInit() :

Code: Select all

    /* configure timer 0 for a rate of 12M/(1024 * 256) = 45.78 Hz (~22ms) */
    TCCR0 = 5;      /* timer 0 prescaler: 1024 */



Thanks for helping

Post Reply