has anyone some kind of documentation how to implement an own flashing-procedure for an atmega8-microcontroller ?
when searching, i have only found tutorials, on how to flash custom software with the normal flashing-software (in most cases atmels flip), but i havenĀ“t found any documentation, how you would implement it in your own software. eg. what are the commands in which timings and with which responses from the microcontroller.
so, thank you in advance
You program the chip by communicating with it through SPI lines while it is in reset. You can find details in the chip's datasheet.
You can't do that directly from your PC, you need to have an external hardware device (even if it is a mere level converter connected to your serial/parallel port). How you communicate with that device depends on the device.
If you want to implement bootloader functionality, you should take a look at boot_page_write() function in avr-gcc help. Basically what you need is the data stream from PC/other uC which will accumulate in RAM until you have enough to write one page.
You can search for AVR Universal Boot loader for example how it can be implemented.
Related
I am developing C++/Qt application which interacts with Tektronix TDS2002 oscilloscope via USB. The oscilloscope appears as "USB Test and Measurement device (IVI)".
Currently I use TekVISA library supplied by the oscilloscope's vendor. It works, but it is huge, old, buggy and poorly maintained. Therefore I would like to bypass the library and interface the device directly.
So far I have found this simple library: https://github.com/xyphro/WinUsbTmc It is exactly what I am looking for, but it uses libusb which requires to install some device filter and in addition it is advised to be more development tool than customer solution. Do you have any experience on this?
What is the easiest way to interact with USB Test and Measurement device in Windows/C++/Qt?
Thank you for your suggestions :)
You need a USB driver. My oscilloscope works with the driver included in this VISA package (the driver can be extracted very easily): http://www.keysight.com/main/software.jspx?cc=CZ&lc=eng&nid=-11143.0.00&id=2504667&pageMode=CV I assume all USB TMC devices can use the same driver, but I have no possibility to check this.
USB driver can be accessed via standard Windows functions. Guys on this forum were really close:
https://forum.tek.com/viewtopic.php?f=568&t=137573 and also this document was very useful: http://www.ivifoundation.org/downloads/Class%20Specifications/Ivi-6%202_USBTMC_2010-03-23.doc
You cannot write commands to OSC directly - data you send and receive have certain header which has to be in the correct format, otherwise the oscilloscope ignores the message. See reading and writting implementation in this simple library: https://github.com/xyphro/WinUsbTmc I didn't use this library because it uses libusb library which uses some kind of device filter and I personally do not like this concept (and in addition I have genuine working driver).
Data you read have also a simple header. To ensure you fit the header structure on input data well, you should first flush the input buffer. Then you issue reading request (using write command - see WinUsbTmc library above) and finally you receive the data and fit the header on its beginning.
I hope this will help to somebody :)
With regards
klasyc
How does one begin writing drivers for Windows? Is there some sort of official DDK "Hello World" example out there?
While I'm sure it will be way above my head at first, eventually I would like to create a simple MIDI driver, much like the Maple Virtual MIDI Cable where the MIDI messages come from a user application rather than a physical device.
(The trouble with using the off-the-shelf MIDI loopback drivers is that the existence of an input and output end is often confusing for the user. My application generates MIDI output that gets sent to the MIDI input of other programs, so if I could create a fake driver that connects to my program rather than hardware, it would eliminate this confusion.)
Thank you for your time.
The WDK docs are reference material, they won't teach you how to get started. Essential are the sample code included with the WDK, there's lots of it and you can often find something that resembles the kind of driver you want to create. A generic filter driver is available in the src\kmdf\toaster\filter directory, I think that's what you'd need if I understand your goal properly.
Walter Oney's books are essential to learn important concepts, strongly recommended. I keep running into osronline.com as a web site that strongly focuses on driver development, with forums. You typically won't find much help here, it is a rather specialized kind of coding.
You could take a look at my virtualMIDI-driver:
www.tobias-erichsen.de/virtualMIDI.html
This one does exactly what your are looking for.
Tobias
I am new to hardware programming(especially USB) so please bear with me and my questions. I am using C++ and I need to send/receive some data (a byte array) to/from a USB port on a microprocessor board.
Now, I have done some serial port programming before and I know that for a serial port you have to open a port, setup, perform i/o and finally close the port. I am guessing to use a USB port, it is not as simple as what I mentioned above.
I do know that I want to use Microsoft standard drivers and implement standard Windows IO commands to accomplish this, since I believe there are no drivers for the microprocessor board for me to interact with.
If somebody can point me in the right direction as to the steps needed to "talk" to a USB port (open, setup, i/o) via standard Windows IO commands, I would truly and greatly appreciate it. Thanks you so much!!
USB in a nutshell is excellent background reading.
For a generic USB module try LibUSB which includes some examples of talking to standard devices. LibUSB-Win32 is the windows port of that library.
You're right though, it's nowhere near as simple as an RS232 port.
What microprocessor are you using? Does it come with any USB hardware or are you thinking of trying to implement it all in software (not something I'd recommend even contemplating!). A lot of microprocessors come with code samples which can emulate simple HID USB devices like keyboards / mice etc. which you can use as a starting point. Failing that, there's probably a few off-the-shelf options which will save you a lot of headaches :-)
Find out the USB chipset used on the microprocessor board, e.g. Ftdi, Cypress, etc. These manufacturers supply drivers, libraries and example programs for the comms, this is the easiest way.
There are no 'standard' drivers as such unless your board is set up as an HID device, however if you are using Windows, Microsoft supply a WinUSB.sys 'generic' driver which may or may not meet your needs (it doesn't support Isochronous transfers).
Should you write a driver for the USB device that will attach itself. If you know the type of chip that has the USB i/o on the board, the driver will be for that device.
There may already be driver's for that chip if it is an STM or there may be an API to help develop drivers for it. It would probably be a custom device but you should look through device types to see if there is an existing type that matches your device. If so there may also be a driver already for it which you can use. Information about the board is necessary.
WRITE YOUR OWN DRIVER
With out getting too far into it, you should learn Microsoft's driver model, the difference between user mode and kernal mode drivers, what driver node's represent, driver hierarchy and how they logically attach themselves, different types of drivers (filter, function, bus), how kernal driver's communicate with user interface, dynamic link libraries, frameworks and API's, WDM framework/API, KMDF and UMDF API's and this is just a short list.
OR you can use an existing driver.
USE USB MICROCONTROLLER SUPPLIED DRIVER
We do not know what firmware the USB microcontroller is using, if any. If there is no firmware (if say the chip came with out it or relies on eprom to store it and not flash) then if we knew if the chip supports usb bootloader, you can flash it or load it's firmware through the USB and there is no need for JTAG or other peripherials. Likely the usb alone is capable of getting you off the ground and anywhere from there. Typically these types of questions arise when considering board's with out a USB microcontroller.
Here is a link to a slighly related driver. Most USB microcontrollers serve the purpose of switching USB communication to UART as most microconrollers that actually do the thinking and control everything are not equiped with USB i/o but instead UART or some other i/o pins like I2C or SPI etc..
https://www.silabs.com/products/mcu/Pages/USBXpress.aspx
That driver may actually work, if not something similar but for the manufacturer of your USB microcontroller; will almost certainly do the job. Hope this helps.
By hardware programming, do you mean you will be programming the microcontroller? If so, there is no way you will use "standard windows drivers" or anything like that.
The USB standard is very thick. Check it out here
It is a very involved topic and I recommend finding USB implementations already created for your microcontroller. (which we may be able to find if you gave us more info)
What kind of microprocessor and what kind of board?
Many processors come with support for USB ports. Also, some hardware boards come with USB contollers too.
For example, the processor that my shop is using comes with two USB controllers that can act as a hub or as a device. We're even adding another processor to act as a USB controller.
I want to develop code to transmit data from system to PIC through USB.
Can anybody give good link regarding data transmission through USB.
because i am new to this.
NOTE: Very simple is code is enough to me.
Thanks in Advance
The PIC16F877 does not have a USB peripheral built in. I assume that the product that you are building is a "USB Device" and that the "system" that you are referring to will provide the USB host functionality. If this is the case then you will have to add a USB interface chip to your hardware to provide async serial to USB connectivity. Suitable devices are made by TI (TUSB series) or FTDI. You then connect one of these to the PIC internal USART and pretend that you are transferring the data over a simple serial port. If you are using a pc then the connected device will appear as a standard COMn: port.
I totally agree with the FTDI route, however if you're not looking for a UART tunnel over USB then you have to get a bit more in-depth.
You'll have to write the USB routines yourself or find libraries/projects for your processor. What you will definitely have to have is a fast clock - 12MHz is necessary More is better because on small uC's like these you'll spend most of your time just handling the basics of USB - signaling and so forth. You'll also need a fair bit of memory because the USB code takes up around 1.5K I think. Then you need room afterwards for your own code.
I've seen the V-USB (http://www.obdev.at/products/vusb/index.html). It's for AVR not PIC, but it says it provides all of the USB functionality you'll need and even provides vendor and product IDs for you to use (non-commercial I believe). There's also a PIC project for USB that doesn't run on the same hardware as yours here: http://www.alanmacek.com/usb/
To make the driver you'll have to use libusb - here's a link for the win32 version: http://libusb-win32.sourceforge.net/
It's surprisingly more simple than I had expected, but I just looked at example code and not actually made anything. Good luck!
As your task will involve Windows Device Driver development, I do recommend to downlaod and install the WDK and look through the contained sample USB drivers.
This might get you some hints about the complexity of the topic. Device driver development is not the easiest thing to start with.
Maybe you can start with UART communication (RS232).
check http://www.beyondlogic.org/usbnutshell/pic16f876.gif will surely help u
also
ttp://www.beyondlogic.org/usbnutshell/usb7.htm , type h in front of 2nd link.
I am trying to connect to a single USB device using the USB host port on an Atmel processor. I have an embedded system with limited memory and no OS. I want to implement a simple dedicated host to interface to a single USB slave device.
Can anyone guide me to a simple USB host implementation?
The processor is the Atmel AT91SAM9261S.
First of all if i remember correctly AT91SAM9261S have OHCI usb controller on board and you need to implement at least simple host controller driver (you can take a look on Linux implementation) . Depending on the transfer types your device will be using it might be not very hard - to very hard :) There is no trivial way to implement usb stack.
After implementing a controller driver you will need to take care usb device enumeration part take a look at Chapter 9 of USB spec. And only after this you can start implementing your device logic.
For simplified use case there is a lot of code that could be omitted, but without good usb background is hard to decide what is relevant and what is not.
Any way if you are looking for commercial solution my company can provide one.
I've used the RTUSB-32 stack from On-Time. It is a small foot print stack and was easy to integrate into our environment and the documentation is good. They abstract out nicely the needed support so that it is completely platform and OS neutral and has a relatively small number of hooks you need to provide to it - ie: It is well encapsulated.
Since you get all the source, you'll see that the code is not the most well constructed code in the world, certainly, but it can be deciphered without a whole lot of work if needed. In any case, it basically "just works" without issue. We have had it running in some products for a few years now and have only run into one compatibility problem with the stack where it wasn't quite doing auto-discovery quite right with a certain type of USB 2.0 hub. We sent them a sample of the hub and they had a patch for it within a few days. Hard to beat that. Overall, I consider it a good value and certainly beats sitting down to write the thing from scratch.
This would be so much easier if your device didn't have to be a host :-P, because Atmel provides example source code for USB devices. If I were you, I'd look into using one of the USB-loving RTOSs on Atmel's AT91SAM third party page which might entail the USB stack from jungo as suggested by Ilya.
If you do write your own OHCI driver, libusb could be helpful as an implementation of the upper layers of the USB stack.