Chameleon-PIC Nurve Networks, Chameleon-PIC Datasheet - Page 230

MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)

Chameleon-PIC

Manufacturer Part Number
Chameleon-PIC
Description
MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)
Manufacturer
Nurve Networks
Datasheet

Specifications of Chameleon-PIC

Processor To Be Evaluated
PIC24
Data Bus Width
16 bit
Interface Type
USB, VGA, PS/2, I2C, ISP, SPI
Operating Supply Voltage
3.3 V, 5 V
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Technical Overview
This demo really shows off the UART and bi-directional communications. Not only are we printing to the UART for display
on the terminal on the PC, but we are getting input from the terminal and processing it, so it’s a very complete two way
communications demo. Also, there are some animations and fun techniques that are used to display the logon logo and
other effects to “sell” the game. For example, the intro logo is an array of data that is used to print out “WarGames”:
// the title screen bitmap as a matrix of byte, stored in FLASH for fun, then to render we will convert to
// characters: BLOCK and SPACE
// notice the use of "const" and "PROGMEM", also to access the array, we must use "pgm_read_byte( addr )"
// size of banner 52x5
const unsigned char title_string_flash[] = {
0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,
0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,
0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,1,0,1,1,1,0,0,1,1,1,1,1,0,
0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,
0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,1,0,
};
The interesting thing about this array is that its defined in FLASH memory rather than SRAM, so this demo shows how
you do that. Notice the keyword const before the array declaration? This instructs the compiler to place the array in
FLASH rather than SRAM. However, this isn’t without side effects. Now that the data is in FLASH, you can access it as
normal data. For example, later in the code when the logo is displayed, the following function reads the data, displays it on
the terminal, and makes some sounds:
// draw "WAR GAMES" with characters from FLASH
for (index = 0; index < 52*5; index++)
I have highlighted the special function needed to access FLASH based storage, the pgm_read_byte(…) function. This is
all you need to get to the bytes of the FLASH with a pointer.
The remainder of the main program is more or less printing strings with timing and a bit of conditional logic; however,
there is one function that is the workhorse of the program and that’s the Get_String(…) function. When programming,
most programmers are completely oblivious to the underlying code in printf(…) or scanf(…) and so forth, but in
embedded systems we can’t use these calls since they usually have no meaning and we need to write them ourselves!
Alas, in this case, we need some kind of simple single line text editor, so the user can type on the screen, backspace, etc.
and do a few reasonable “edit” related keystrokes. The terminal program has no idea about this and nor does the UART,
the UART just receives ASCII characters, thus we need to write a single line text processor to make this work. The
function listing of this code is below.
int Get_String( char *cmd_buff, char **tokens )
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// this function waits for the user to input a string on from the UART, it supports some
// editing such as backspace. When the user hits "return" the string is tokenized into an array
{
// read the image from FLASH memory with special function call that uses
//
c = title_string_flash[ index ];
// based on data convert to character and send to UART
if (c == 0)
else
if (c == 1)
if ( (index % 52) == 0)
DELAY_MS(50);
} // end for
{
Sound_Play(0);
UART_Print_String(" ");
}
{
Sound_Play(2000);
UART_Print_String("#");
} // end if
UART_Print_String("\n");
"LPM" ASM instruction to read FLASH
© 2009 NURVE NETWORKS LLC “Exploring the Chameleon PIC 16-Bit”
230

Related parts for Chameleon-PIC