PIC related website
Hi,
The unit "StrngUtils" has been replaced with a new version:
- more efficient code in "trim", "delete" and "insert" routines,
- only one level of stack usage (eliminated the calls to "length").
Have fun
The unit "StrngUtils" has been replaced with a new version:
- more efficient code in "trim", "delete" and "insert" routines,
- only one level of stack usage (eliminated the calls to "length").
Have fun
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi, added a small drawing now about the USB A and B PCB connector pinning. See "Tips", "USB PCB Connector_Pinning".
Have fun.
Have fun.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi, the unit "StrngUtils" has been extended with the following "Pad" procedures:
Have fun!
Code: Select all
procedure PadLeft(Var Str: string[255]; Len: byte);
// Makes the length of "Str" "Len" characters by adding spaces at the beginning of "Str"
// Make sure "Src" can hold "Len" characters (no check possible!)
// If the length of "Src" was already "Len" or more characters then "Src" is not changed.
procedure PadRight(Var Str: string[255]; Len: byte);
// Makes the length of "Str" "Len" characters by adding spaces at the end of "Str"
// Make sure "Src" can hold "Len" characters (no check possible!)
// If the length of "Src" was already "Len" or more characters then "Src" is not changed.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
A new unit has been added: the USB_HID_library.
See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm. The interface is somewhat different than the one of mE.
The "Descriptor" part of the "HID Terminal" tool is not used any more. In stead the descriptors are embedded in the library and adapted according the values set in the file "USB_HID_ProjectItems.ppas" (see further).
The main part of the unit's interface is:
As also mentioned on the web the following holds:
The source code is published, so feel free to debug and enhance it!
Have fun.
A new unit has been added: the USB_HID_library.
See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm. The interface is somewhat different than the one of mE.
The "Descriptor" part of the "HID Terminal" tool is not used any more. In stead the descriptors are embedded in the library and adapted according the values set in the file "USB_HID_ProjectItems.ppas" (see further).
The main part of the unit's interface is:
Code: Select all
{ ---------------------------- USB_HID Library Interface -----------------------
procedure InitUsb;
// Initializes USB HID and starts the uSB enumeration process.
function ConfiguredUsb: boolean;
// Returns true if the USB enumeration process was completed and successful.
function USB_HID_Read(DstPtr: ^byte; MaxLen: byte): boolean;
// Returns true if some data has arrived, false means: no data arrived.
// The arguments are:
// DstPtr: the address of the user defined receive buffer.
// MaxLen: the actual number of received bytes to be copied into the user defined receive buffer
// (can be less than or equal to the size of the user defined receive buffer).
function USB_HID_Write(SrcPtr: ^byte; ByteCount: byte): boolean;
// Returns success as true, false means: try later again (USB sendbuffer was still busy).
// The arguments are:
// SrcPtr: the address of the user defined send buffer.
// ByteCount: the actual number of bytes to be sent
// (can be less than or equal to the size of the user defined send buffer).
procedure DeInitUsb;
// Stops and disables USB HID.
procedure SoftDetachUsb;
// Disconnects USB from the "host" and connects it again,
// restarting the USB enumeration process.
As also mentioned on the web the following holds:
An example of usage:Intended for the PIC18F2455/2550/4455 and 4550 PIC's or PICs with the same USB SIE.
Derived from the "TB054" publication of Microchip. No knowledge of USB "descriptors" required.
Warning: before usage one should delete "USBGenHID" from both the files "P18Fxxxx.mlk" and "P18Fxxxxdef.ppas"
in "C:\Program Files\MikroElektronika\mikroPascal\defs". Once deleted, a restart of mikroPascal is needed.
Example project: http://www.rosseeld.be/DRO/PIC/USB_Demo.ppas: the main (demo) project, and http://www.rosseeld.be/DRO/PIC/USB_Demo.ppp, the ppp file (8 Mhz crystal used).
Important: For each project using the library, a separate version of "USB_HID_ProjectItems.ppas" should be available (it is "used" by the library), residing the the project's directory itself. The libary itself ("USB_HID_Library.ppas") can reside in a common directory.
Code: Select all
program xxx;
uses USB_HID_Library;
var I: byte;
ReceiveBuffer: array[5] of byte;
SendBuffer: array[5] of byte;
...
procedure InitMain;
...
end;
procedure interrupt;
begin
USB_Interrupt; // <--- necessary call to the library
end;
begin // main
InitMain;
InitUsb; // Init Usb and start enumeration process
repeat until ConfiguredUsb; // wait for the completion of the USB enumeration
while true do // main loop
begin
// read data from the USB-HID interface and echo it
if USB_HID_Read(@ReceiveBuffer, SizeOf(ReceiveBuffer)) then // USB data came in
begin
for I := 0 to SizeOf(SendBuffer) - 1
do SendBuffer[i] := ReceiveBuffer[i]; // simply echo
repeat until USB_HID_Write(@SendBuffer, SizeOf(SendBuffer)); // send
end;
end;
end.
Have fun.
Last edited by Dany on 27 Oct 2010 09:53, edited 2 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi, the "USB_HID_Library" has been updated:
- the strings identifying manufacturer, product and productversion have been moved to constant memory (defined now in "USB_HID_ProjectItems.ppas"), just like the ID's for vendor and product already were.
- The endpoint receiving data from the host is used now (EP1Out) in stead of the "set report" feature. The host will wait now until the out buffer has been read by the PIC's software.
Have fun!
- the strings identifying manufacturer, product and productversion have been moved to constant memory (defined now in "USB_HID_ProjectItems.ppas"), just like the ID's for vendor and product already were.
- The endpoint receiving data from the host is used now (EP1Out) in stead of the "set report" feature. The host will wait now until the out buffer has been read by the PIC's software.
Have fun!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi, the "USB_HID_Library" has again been updated (version 11-10-2008 now):
- some constant names have been changed to comply with those used by Microchip,
- the code for endpoint "GetStatus", "ClearFeature" and "SetFeature" has been corrected.
Have fun!
- some constant names have been changed to comply with those used by Microchip,
- the code for endpoint "GetStatus", "ClearFeature" and "SetFeature" has been corrected.
Have fun!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
A new unit has been added: the "USB_CDC_Library".
See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Please read the documentation present on the website.
On the website also the necessary PC software (including sources and executable) and the windows driver can be found.
Have fun!
A new unit has been added: the "USB_CDC_Library".
See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Please read the documentation present on the website.
On the website also the necessary PC software (including sources and executable) and the windows driver can be found.
Have fun!
Last edited by Dany on 27 Oct 2010 09:54, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
A small article has been added about the clock settings for USB PIC devices. This activity is not so easy if one has to do it for the first time (as I did a short while ago). I hope this article helps somewhat.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Have fun.
A small article has been added about the clock settings for USB PIC devices. This activity is not so easy if one has to do it for the first time (as I did a short while ago). I hope this article helps somewhat.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Have fun.
Last edited by Dany on 27 Oct 2010 09:55, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
A small article has been added about the usage of mE's USB HID library.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Have fun!
A small article has been added about the usage of mE's USB HID library.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.
Have fun!
Last edited by Dany on 27 Oct 2010 09:55, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
The unit "StrngUtils" has been extended with these two:
Have fun.
The unit "StrngUtils" has been extended with these two:
Code: Select all
procedure WordToHexStr(Val: word; var S: string[4]);
// Converts a word to its hexadecimal string representation
procedure LongintToHexStr(Val: longint; var S: string[8]);
// Converts a longint to its hexadecimal string representation
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi all,
The "PC side software" for use with the "USB_CDC_Library" has been changed: the serial port "writetimeout" has been adapted (= not zero any more). Reason: better write synchronisation from PC to PIC.
The write speed (pure transfer speed with only a "read buffer" at the PIC side) to the PIC (with my PC anyway) is now about 250 kB/sec. I intend to (in the future) make a library that uses the so called ping pong buffer method, which should make the speed approximately twice as high.
Have fun!
The "PC side software" for use with the "USB_CDC_Library" has been changed: the serial port "writetimeout" has been adapted (= not zero any more). Reason: better write synchronisation from PC to PIC.
The write speed (pure transfer speed with only a "read buffer" at the PIC side) to the PIC (with my PC anyway) is now about 250 kB/sec. I intend to (in the future) make a library that uses the so called ping pong buffer method, which should make the speed approximately twice as high.
Have fun!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Hi, I did correct a small string descriptor problem (only a potential problem, not an actual one yet) in both the USB (HID and CDC) libraries.
Have fun!
p.s. progress on the "CDC ping pong buffer" project (I get further in the enumeration procedure now) , but not working yet.
Have fun!
p.s. progress on the "CDC ping pong buffer" project (I get further in the enumeration procedure now) , but not working yet.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
LCD1602 Lib
Dany,
First of all .. many thanks for your nice libs ..
I started to use your libs one by one .. and leave the "blind" libs of mikroe more and more behind, because you made it open source .. and see what happens .. I now use your 1602 LCD lib and noticed that some HD44780 type controllers need the "set it in 4 bits interfacing mode with 2 lines" commands twice .. With your lib i was able to find the correct line .. and double it in your code .. and your lib works now fine with my type of display too ...
So .. tip for users of your lib that get only one line in their LCD.
double the line :
In the initialisation procedure.
Again .. many thanks .. Dany .. for sharing your nicely written and documented libs ..
Grx....
Eric
First of all .. many thanks for your nice libs ..
I started to use your libs one by one .. and leave the "blind" libs of mikroe more and more behind, because you made it open source .. and see what happens .. I now use your 1602 LCD lib and noticed that some HD44780 type controllers need the "set it in 4 bits interfacing mode with 2 lines" commands twice .. With your lib i was able to find the correct line .. and double it in your code .. and your lib works now fine with my type of display too ...
So .. tip for users of your lib that get only one line in their LCD.
double the line :
Code: Select all
Lcd1602Send(LCD_FUNCTION_SET + LCD_4BIT_INTERFACE + LCD_2LINES); // 4 bits mode, 2 lines
Lcd1602Send(LCD_FUNCTION_SET + LCD_4BIT_INTERFACE + LCD_2LINES); // 4 bits mode, 2 lines
Again .. many thanks .. Dany .. for sharing your nicely written and documented libs ..
Grx....
Eric
Re: LCD1602 Lib
Hi, thanks for the compliments. Do you have an idea why some controllers need the command twice?velobyte wrote:I now use your 1602 LCD lib and noticed that some HD44780 type controllers need the "set it in 4 bits interfacing mode with 2 lines" commands twice ..
Thanks in advance.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)