April 10th, 2007


USB Interfacing with GNU/Linux and PIC 18F2455 - Part 2

It's no wonder that there are so few complete resources on writing USB firmware on the net - there is only one word to describe the process - `tedious'.

The last few days have been spent reading USB Complete - this is the only good book available to help you get along ... it's extremely well written. This book, combined with the code ofPUF framework seems to be the best combination for getting started. Another great resource is the code written by Bradley A Minch available from here. I prefer the PUF code because it's better structured - but there seems to be some trouble with the configuration bit definition in it.

Our development environment is now stable. The programmer, `odyssey', is working perfectly and SDCC + gputils seems to be generating correct code. Unfortunately, we were unable to get PUF running on our 18F2455. So we began taking out bits and pieces of code from PUF and started testing them independently. We were able to go as far as initializing endpoint 0 and getting an OUT transaction on it. Now the trouble with USB is that it has a tricky state machine - the way you handle the current transaction depends on what the previous transaction was. You will soon reach a point where you won't be able to test things with 10-20 lines of code - you will have to have the whole state machine running smoothly. So yesterday, Anish `cleaned up' the PUF code taking out a lot of things which were not going to be useful for us at present but keeping the core intact. And, magically, everything started working. Enumeration was succesful and we have endpoint 0 ready to accept control transfter requests!

Understanding Microchip's description of the working of their USB SIE (Serial Interface Engine) is another headache.

Now we have to get some `vendor' requests working and maybe configure another endpoint to do interrupt transfer. I will think of writing a proper tutorial after that.


Elephants, Fireworks and Greedy/Stupid Men

It's that time of the year when the whole of Kerala goes mad with festivals - Hindu's, Christians and Muslim's vie with each other to celebrate religious/quasi-religious occasions with fanfare. The elephant has traditionally been part of temple celebrations; not to be left behind, the Christians and Muslims too have joined in parading these beasts in public. Giving elephants out for rent has become a business. The beasts are treated with scant respect by ill-trained `mahouts' - they are made to stand for long hours in horribly hot weather and frequently `punished'. There is no way elephants can form a union, but they are not taking these insults lying down. Not one day has gone by in the past two months without an incident of elephants getting `unruly' and spreading panic. But yesterday's events were really horrifying. An elephant which was ill-treated by its mahout gored him to death, tried to kill a few others, attacked another elephant, created a sort of stampede which resulted in 17 people getting injured and in general, provided copious `real-life' thrills to an audience of Malayalis growing stupid day by day watching endless TV serials.

The elephant has become a real threat to life and property in Kerala. But you will never find a report in the popular press questioning the logic behind letting dangerous beasts mingle freely with large crowds. These beasts have become a valuable source of sensational news - the press loves them.

The residents of Trichur are going to witness another act of lunacy - the Pooram fireworks. The concerned temple authorities say that without this great act of `tradition', the Pooram is meaningless. They are willing to detonate high-explosives in the middle of the town, right in the midst of a huge crowd, unmindful of the dangers which are so obvious just so that `tradition' is upheld. The highly `literate' population of Trichur is backing them wholeheartedly. Some attempts are underway to `restrict' the fireworks - but I am sure the local neta's, business men, temple authorities and the `spirited' public will gang together to make sure that the maidan at the centre of the town erupts into fire on the appointed day ....

Update: The Malayala Manorama reports that absolutely NO restrictions will be placed on the fireworks display.