<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/11494" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2018-09-04T16:19:19+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/11494</id>

		<entry>
		<author><name><![CDATA[reptooyep]]></name></author>
		<updated>2018-09-04T16:19:19+02:00</updated>

		<published>2018-09-04T16:19:19+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11494&amp;p=34634#p34634</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11494&amp;p=34634#p34634"/>
		<title type="html"><![CDATA[HIDKEYS example modified with 20MHZ clock not recognize]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11494&amp;p=34634#p34634"><![CDATA[
Hi everyone,<br />I'm playing with avrs since few years now and i'm locked on a problem.<br />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..)<br />I have an old NAVIONICS GPS and want to put the raspberry in it and keep the existing keyboard.<br />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).<br />I've modified the example to fit my hardware :<br />i use 1.8kohm pullup for D- and 3.6v zener diodes on both D+ and D-<br /><br /><div class="codebox"><p>Code: </p><pre><code>#define F_CPU 20000000UL</code></pre></div> in main.c and every h files<br /><br /><br />The new keyboard function works the same (returns 1 to 10 for each key and 0 for no key)<br /><div class="codebox"><p>Code: </p><pre><code>static uchar    keyPressed(void)<br />{<br /><br />uchar   i;<br />   uint8_t bits = PINC;<br />   if (!(bits &amp; 1)) i=1;                  //Si un des bits est a 0 (!), i=valeurs correspondante<br />   if (!(bits &amp; 2)) i= 2;<br />   if (!(bits &amp; 8)) i= 3;<br />   if (!(bits &amp; 16)) i= 4;<br />   if (!(bits &amp; 32)) i= 5;<br />   if (bits &amp; 59) i=0;                     //cas ou tout est a 1 (32+16+8+2+1), pas de touche =&gt; i=0<br />   bits = PINB;<br />   if (!(bits &amp; 2)){<br />       i= 0;<br />      PORTC ^= (1&lt;&lt;PC2);                  //^= : bascule<br />      _delay_ms(10);                     //anti rebond (appui multiple)       <br />   }<br />   if (!(bits &amp; 16)) i= 6;<br />   if (!(bits &amp; 32)) i= 7;<br />   if (bits &amp; 50) i=0;                     //cas ou tout est a 1 (32+16+2), pas de touche =&gt; i=0<br />   bits = PIND;<br />   if (!(bits &amp; 2)) i= 8;<br />   if (!(bits &amp; 32)) i= 9;<br />   if (!(bits &amp; 128)) i= 10;<br />   if (bits &amp; 162) i=0;                  //cas ou tout est a 1 (128+32+2), pas de touche =&gt; i=0<br />   return i;                           //A la fin, on retourne la valeur de la touche (0 = pas de touche et de 1 à 10 : une touche)<br /><br />}</code></pre></div><br /><br />When i plug the device, windows says :&quot;USB device not recognized etc ...&quot;<br />The toggling lights works.<br /><br />Is there anything else to modify in order to use 20MHZ ? <br />I'm thinking about the 22ms delay :<br /><div class="codebox"><p>Code: </p><pre><code>        if(TIFR &amp; (1&lt;&lt;TOV0)){   /* 22 ms timer */<br />            TIFR = 1&lt;&lt;TOV0;<br />            if(idleRate != 0){<br />                if(idleCounter &gt; 4){<br />                    idleCounter -= 5;   /* 22 ms in units of 4 ms */</code></pre></div><br /><br /><br />or the timer in hardwareInit() :<br /><div class="codebox"><p>Code: </p><pre><code>    /* configure timer 0 for a rate of 12M/(1024 * 256) = 45.78 Hz (~22ms) */<br />    TCCR0 = 5;      /* timer 0 prescaler: 1024 */</code></pre></div><br /><br /><br />Thanks for helping<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=23865">reptooyep</a> — Tue Sep 04, 2018 4:19 pm</p><hr />
]]></content>
	</entry>
	</feed>
