Archive for July, 2010

PSOC Designer 5.0 code porting

Cypress switched back to the ImageCraft compiler, and now we’re left with the task of fixing our existing codebase that was developed with the HiTech compiler.

Not too problematic. The only thing that bothers me a bit is the lack of good/up-to-date documentation. I spent an hour to figure our how to get the printf’s that I used in my code compiling again. Once you know how to do it, it is simple…

Example code:


printf("Test printf without parameters\n");

Compiling your HiTech code with the ImageCraft compiler, the printf fails with the following error:


type error in argument 1 to `printf'; found `pointer to __flash char' expected `pointer to char'

Seems that in for ImageCraft you need to use another printf function if the strings are in ROM. And this function is called… tada: cprintf.

Replace the existing printf with cprintf and you’re up and running again. I guess it would have need nice if this info was added to the ‘migrating from HiTech to ImageCraft’ document that is bundled with PSOC Designer. Maybe eventually, it will be…

Also notice: to get the ImageCraft printf functions working, you need to replace the ‘putch’ helper function for printf by:

// Helper function for the printf function.
int putchar(char c) {
 // Send characters to the Lantronix interface
 LTRX_PutChar(c);
 return 1;
}

Finally, if you fancy some more advanced printf functionality like modifiers, or support for long/float, you’ll need to update your ‘local.mk’ (‘Project’ -> open local.mk) and add the option

CODECOMPRESSOR:=$(CODECOMPRESSOR) -lfpm8c // For floating

CODECOMPRESSOR:=$(CODECOMPRESSOR) -llpm8c // For long support

Hope this helps you saving some time until the documentation gets updated!

Garmin simple text convertor script

I needed to test some XBee long-range radios. Hmm, how can we make this test useful and fun at the same time? Well, let’s put one end of the radio in the lab connected to a computer, and wander around with the other radio while transmitting the current position obtained from a GPS.

Using the XBee evaluation kit, my (t)rusty eTrex GPS, a 12V battery and some cables, the hardware was quickly in place. Now, what to transmit over the link? Full NMEA? Hmm, maybe this is a bit overkill. Sending the position once a second ought to be enough. But then I need a microcontroller between the GPS and the radio to reformat the NMEA into simple position beacons. There has to be an easier way…

Read the rest of this entry »