Hi All
It is with great pleasure that I announce that the M5223X SP8 is available on the service pack side:
http://www.utasker.com/software/softwareV1.3.htmlThis service pack adds USB device support for use with the M5221X and M5222X families - see an overview of the devices in the following thread:
http://www.utasker.com/forum/index.php?topic=256.0In addition to the new USB support, there are various more subtle improvement such as HTTP POST for both parameters and files -
the previous SP didn't support posting parameters. The parameter system has been separated from the file system in order to improve its flexibility. It is advisable to check through the release notes to see what may be important for yourself.
As usual, there is a reference
config.h file (
config_ref_m5223X_sp8.h) which was used for release testing and contains all latest defines as reference. It can be renamed to
config.h to reproduce the release state.
There is one change which affects compatibility so it's worth mentioning here:
_CLEARBITS macro has been changed to use positive logic rather than negative logic.
Eg.
_CLEARBITS(TC, PORT_TC_BIT2); clears
PORT_TC_BIT2 in port
TC - previously this was written as
_CLEARBITS(TC, ~PORT_TC_BIT2); All driver files using this form have been adjusted, but it will be necessary to modify its use in any of your own existing application files.
USB device operation is essentially very simple: you put messages to be sent in buffers so that they can be picked up by the host and you receive data in buffers. But to put it all together requires a lot of study, programming, testing and optimising - it is only after reading a few books about it, experimenting and then re-reading the books again that it slowly all starts to fit into place. I wrote an introduction to the theme some time ago, but didn't feel ready to follow it up until I had the feeling of really getting to grips with it all:
http://www.utasker.com/forum/index.php?topic=176.0But now I do feel that the state of the SP really has the potential to form the base of powerful and efficient projects and it is thus time to put it into action!
To get the ball rolling, here is a very quick step-by-step of how the new package can be test-driven. It concentrates on communication (although the embedded side actually doesn't really need to know much at all about the USB model being used) since I found this the most practical way to get something working without having to take a course on Windows Driver programming... it is also very practical for using older PC programs based on serial COM since these usually require no modification at all - they just can work rather faster and seem more 'modern'.
The following allows the M52211EVB, M52223EVB or M52221DEMO to be used (the M52210DEMO can also be used, but doesn't allow firmware upload via USB since it doesn't have adequate FLASH memory).
Simulator (just checking configuration and enumeration for the moment):
1. Install SP8
2. Rename
config_ref_m5223X_sp8.h in the application directory to
config.h3. Delete the file
resource.h in the application directory (there is a new version in
\winsim and deleting the old one will avoid it causing errors).
4. In
config.h activate the processor type and the board type (eg.
_M5222X and
M52223EVB).
5. Rebuild all and start the simulator
6. In the (new) menu
USB, command
"enumeration". This will play a typical enumeration sequence through the code (it allows the operation of the driver to also be studied) and if successful the USB sign lights up red.
7. When the menu point
"Disconnect" is activated it will perform a USB suspend. All transmitted USB data will be logged to a file called "
USB_Endpoint_00.txt" Only endpoint 0 is used during enumeration, otherwise there is a file for each endpoint.
8. It is possible to exercise the USB interface (and others) by playing 'sim-files' through the simulator - in the Menu "Port Sim" - but this subject can be discussed later - for the moment this should do and we can move on to the target...
With the chosen board ready:
1. Open the CodeWarrior projects in
\Applications\uTaskerV1.3\CodeWarrior_M5223X\uTaskerV1.3 and
\Applications\uTaskerBoot\CodeWarrior_M5223X. Use CW7.1 for this since older versions don't support the M5221X and M5222X (at least not properly). Open two incarnations of CW7.1, one with each of the projects (boot loader and V1.3).
2. Chose the targets M52211_BM_ROM (uTaskerV1.3) and M52211EVB (boot loader) -this is suitable for all of the mentioned boards.
3. Compile both projects.
4. In the boot loader project select the Flash programmer setting to suit your processor and delete the entire FLASH. Then load the boot loader project to the board.
5. In the uTaskerV1.3 project select also the same Flash programmer setting but
don't erase the FLASH - just program the project to the board. Now the boot loader and application are loaded.
6. Allow the board to start - it should blink an LED at 2.5Hz rate. Connect the USB cable to your Windows PC, which should cause it to enumerate and start looking for a driver. It will probably not find the driver by itself so, when it asks, tell it to look in the directory
\Applications\uTaskerV1.3\USB. You will have to give Windows permission to install the driver (which actually means copy the file that it has found to a directory where it keep all such files) and then it should be ready to use.
7. In the device manager you should see that the board is visible as a COM port (with name
"uTasker driven device") - the COM port number that it receives depends on the PC but can be changed by opening up the characteristics of the COM entry seen and changing it in the extended options.
8. Open a terminal emulator on this port (I recommend TeraTermPro (
freeware available at various locations on the Internet) - although it only supports COM1..COM4) and hit the enter key. You should get the uTasker serial menu as response and you can then perform commands as known from the original project via UART or TELNET.
9. Connect a second terminal emulator on UART1 of the demo board. When the USB menu is not being used, the UART can access it. When the UART is not using it, the USB can access it. (note that this has default 19'200baud but changes to the setting of the USB connection when this is attached to a terminal emulator!!).
10. Go to the UART menu (from either serial or USB connection) and enter "usb-serial". Now the board operates as a USB/RS232 adapter. You can perform bidirectional file transfers to test its performance. Changing the setting of the USB connected terminal emulator also changes the boards UART settings.
11. Disconnect the USB cable, close the terminal emulator connected to the virtual USB COM ports and connect the USB cable again. The board will immediately enumerate again.
12. Start the terminal emulator on the USB virtual COM port and go to the USB menu again. This time enter "usb-load".
This will result in:
Please start download:
#Don't type anything else in for the moment!
13. Go to the CW program for the uTasketV1.3 project and make a small change (eg. change the version number in application.h from 1.3.008 to 1.3.009):
#define SOFTWARE_VERSION "V1.3.009"Then recompile.
14. In the target directory
\Applications\uTaskerV1.3\CodeWarrior_M5223X\uTaskerV1.3\bin execute the bat file
BM-Convert.bat (double click on it) to create a down-loadable target called "
H_Upload.bin".
15. In the terminal emulator send this file to the USB port. Using TeraTerm you can use
File | Send File.. but
make sure that the option "binary" is set!!! The binary file will be sent and the target will reboot. After rebooting the new program will be loaded and executed.
Note that the USB connection will enumerate again and it is necessary to restart TeraTerm so that it will work again with the interface (in fact TeraTerm has to be closed
before enumerating...).The new version number is displayed when the menu is entered so this allows the success of the upload to be verified.
This should give a quick first impression. Later you will find that the embedded user code to do this is very simple indeed. The application interface is more or less interchangeable with a standard UART interface!
Good luck with your first tests. There is a lot to be explained but a users' manual is in progress. Comments very welcome...
Best regards
Mark
Patch list:
1. See below in this thread for when using SPI FLASH
2. See the following if using DMA timer support and compiling with GCC:
http://www.utasker.com/forum/index.php?topic=387.msg1560#msg15603. When running the RTC from the main crystal oscillator, and using PLL (not 32kHz crystal as possible with some devices) there is a frequency correction here:
http://www.utasker.com/forum/index.php?topic=550.0