USB Demo from Nathan Herbert

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
E_VH
Posts: 12
Joined: Fri Dec 09, 2011 3:08 pm
Location: Belgium

USB Demo from Nathan Herbert

Post by E_VH » Fri Jan 27, 2012 4:46 pm

Hi Everyone,

Have two questions

1 :
==

Can someone explaine

Device = 18F4550
Clock = 48

// 20Mhz crystal, 48Mhz internal (FS USB)

I'am using a 20 Mhz cristal with clock set at 48 ???

This is necessary for full speed USB use ??

2:
==

How to convert between "QERTY" codes and "AZERTY" codes

Wordpad.exe ==> becomes Zordpq:exe ??

Can substitute the Z = W and A = Q but can't find the code for the period.


Erik

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Post by bitfogav » Sat Jan 28, 2012 11:13 am

1 :
==

Can someone explaine

Device = 18F4550
Clock = 48

// 20Mhz crystal, 48Mhz internal (FS USB)

I'am using a 20 Mhz cristal with clock set at 48 ???

This is necessary for full speed USB use ??
If you look at the datasheet for the 18F4550 USB peripheral then it will tell you that the clock source for full speed USB must be 48Mhz.

So we set "Clock = 48" in swordfish, this sets the clock speed for all the internal functions for swordfish.

We need to setup the oscillator (Clock) for the 18F4550 to run at the clock souce of 48Mhz, we do this by setting up the PPL oscillator mode and this is done by setting something like this:

PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS

This will set the 18F4550 internal oscillator to 48Mhz when using an external 20Mhz crystal. I hope that answers your question.

E_VH
Posts: 12
Joined: Fri Dec 09, 2011 3:08 pm
Location: Belgium

Post by E_VH » Sat Jan 28, 2012 4:20 pm

Yes for the moment this answer is helping me out, thanks.

Hope that further reading on the subject will elucidate the difference between the compiler internals and the real pic cristal.

But i'am still in trouble where to specify in the usb-descriptor that i use an azerty keybord ?
Now I must substitute the a , q, w, z, m codes send and for a period i use
SendKey(54, LeftShift) where period in the demofile = SendKey(55, None) ?


Regards

Erik

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Post by bitfogav » Sun Jan 29, 2012 11:05 am

I dont think you can change the keyboard type - the module is setup for a Qwerty keyboard.
The only thing you could try is to make a copy of the KeyboardDefs.BAS and paste it into your User Library Folder and from there you can change/edit that file to suit your keyboard layout?.

Any files located in your User Library Folder should take priority over any Compiler File.

User avatar
RangerBob
Posts: 152
Joined: Thu May 31, 2007 8:52 am
Location: Beds, UK

Post by RangerBob » Tue Jan 31, 2012 3:46 pm

Hi Erik,

bitofgav is right i'm afraid. There is nowhere in the HID descriptor to specify what layout is in use. It's entirely up to the OS on how it handles the layout.

The software is really just saying which position is pushed (scan code), not what the button actually is (char code). We simply match up the chars to the scancode to make it easier.

As bitofgav said, you'll need to change the definitions in "KeyboardDefs.BAS" to match the characters to the hardware scan codes for Azerty. I did have a look for you but can't seem to find the USB Azerty scan codes. A non-english search may turn up more!

Regards,

Nathan

Post Reply