Published:2011/8/1 22:35:00 Author:Li xiao na From:SeekIC
By Andreas Oyrer
Protocol
A protocol is of course required to ensure that data communications between the PC and the programmer are kept in step. The first byte from the PC to the programmer contains information on the selected microcontroller or memory: the value 1 specifies the 9Cx051 series, the value 2 the 89C5x and 89Sx series. The second byte gives the selected action: 1 to read the signature bytes, 2 to erase and so on. Succeeding bytes contain further information, for example the programming voltage for an 89C5x microcontroller or the page size for a serial EEPROM. When programming, an extra byte is used which gives the number of bytes in each packet. A further byte indicates whether the data packet sent is the last one (byte is zero) or whether further packets follow (byte is 1). When reading, a count of the number of bytes to be read is sent to the programmer. Generally the size is specified in kilobytes or kilobits. The software in the programmer can deduce how to interpret the value from the first bytes that were sent.
After each action the programmer sends a number of bytes back to the PC to indicate that it is ready for more data to be sent or to carry out the next action.
Programmer software
The software in the programmer was written using the Keil jYVision2 C compiler. The main routine first disables the watchdog timer and then takes all pins on the programming socket to 0 V using the function ResetPiogrammeiQ. Next the USB registers are set up.
When the boot loader software in IC1 completes, it disconnects from the USB by taking output pin PUR low so that Rl no longer pulls up to 3.3 V. The downloaded software must set the SDW bit in the MCNFG register to reactivate this output: the programmer will then reappear on the bus.
The PC host then sends a number of SETUP tokens to identify the device and configure its USB interface. These tokens are processed by end-point 0. The data transferred includes the unique address for the device, which is subsequently used to communicate with the programmer. Various descriptors are also transmitted to the host during the setup phase, providing information about the device and its functions and characteristics. These include the report descriptor, which in this case identifies the programmer as an HID-compatible device.
Once all the descriptors have been sent to the PC, initialization of the USB interface on the device is complete and it is ready to operate. The direction of data transfer is specified by a token. If the TUSB3210 detects an IN token, then data, such as status information or a data packet, is to be sent from the programmer to the host. If an OUT token is received, then the data packet is unpacked by the programmer and the payload programmed into the device (assuming that that is the selected action).
HID
The advantage of initializing as an HID-compatible device is that no special Windows driver is required to communicate data between the PC and the programmer. Windows versions from 98SE onwards support this standard.
Under the HID standard, data is exchanged in so-called reports. During USB enumeration the PC provides a number of descriptors. The device descriptor includes information such as the Vendor ID (VID), Product ID (PID), and the USB version supported by the connected device.
The configuration descriptor includes information on the current consumption of the hardware and the number of available endpoints. The report descriptor gives the size and number of reports to be exchanged between the PC and the programmer. It specifies how many bytes are to be sent or received and the function of the attached device (mouse, keyboard, joystick, memory stick etc.).
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/01/Multi_Programmer__One_Size_Fits_All_(4).html
Print this Page | Comments | Reading(268)
Author:Ecco Reading(30197)
Author:Ecco Reading(3462)
Author:Ecco Reading(3182)
Author:Ecco Reading(3662)
Author:Ecco Reading(5233)
Author:Ecco Reading(3249)
Author:Ecco Reading(3390)
Author:Ecco Reading(3531)
Author:Ecco Reading(3936)
Author:Ecco Reading(3708)
Author:Ecco Reading(3678)
Author:Ecco Reading(3715)
Author:Ecco Reading(6029)
Author:Ecco Reading(3693)
Author:Ecco Reading(4479)