Here is the bulk of the code. FWIW i just discovered that if i use this in my code it does not hang up right away it now runs for somewhere in the neighborhood of a couple minutes, then starts updaing the screen slower and slower until finally it stops. whereas before it would only run for about 1-30 seconds. This is not the right way to do it, but its now causing me to look at what other IRQ’s may be firing causing it to break away from my code.
NVIC_DisableIRQ(CC3000_WIFI_INT_EXTI_IRQn);
LCD_Strings(lcdstring,0x80000,20,120,7,0xF4df,0x0000);
NVIC_EnableIRQ(CC3000_WIFI_INT_EXTI_IRQn);
uint16_t hours,minutes,seconds;
// Used for string data to lcd
char lcdstring[50];
//*******************************************************
// Name: GotoXY(x,y)
// Copyright: Free to use at will & at own risk.
// Date: 10.01.12
// Description: To set x,y location registers
// Usage: GotoXY(param 1,param 2)
//
// param 1: x location on screen
// param 2: y location on screen
//
// Example: GotoXY(x,y)
// Notes: No bounds checking
//******************************************************
void GotoXY(uint16_t x, uint16_t y)
{
SPI_WriteCMD(0x2a); // column set
SPI_WriteDAT((uint8_t) (x >> 8));
SPI_WriteDAT((uint8_t) x );
SPI_WriteDAT((uint8_t) ((DISPLAY_WIDTH-1) >>8));
SPI_WriteDAT((uint8_t) (DISPLAY_WIDTH-1));
SPI_WriteCMD(0x2b); // page address set
SPI_WriteDAT((uint8_t) (y >> 8));
SPI_WriteDAT((uint8_t) y);
SPI_WriteDAT((uint8_t) (DISPLAY_HEIGHT-1) >>8);
SPI_WriteDAT((uint8_t) (DISPLAY_HEIGHT-1));
}
//*******************************************************************
// Name: LCD_String
// Copyright: Free to use at will & at own risk.
// Date: 10.01.12
// Desc: To print a string of characters to LCD
// Usage: LCD_String(param 1,param 2,param 3,param 4,param 5,param 6,param 7,param)
//
// param 1: String data
// param 2: Location in external flash.
// param 3: x start direction: 0-x max
// param 4: y start direction: 0-y max
// param 5: char to char spacing in pixels. Pads extra pixels between chars to space them apart
// param 6: Font Color, 5-6-5 format
// param 7: Background color, 5-6-5 format
//
// Example: sprintf(lcdstring,"1234567890");
// LCD_String(lcdstring,0x80000,10,10,5,0x04df,0x0000);
//
//
// NOTES: No x & y bounds checking
//
//*******************************************************************
void LCD_Strings(char *lcd_string, uint32_t font_pointer, uint16_t ux, uint16_t uy, uint8_t char_spacing, uint16_t fcolor, uint16_t bcolor)
{
uint16_t y, y_total, mask, x, data_start, height, width, po;
uint8_t l, m, h, px, dt_start;
uint32_t data_pointer = font_pointer;
static uint8_t my_data[512];
// Get the height value for the font
data_pointer +=6;
sFLASH_ReadBuffer(my_data,data_pointer,1);
height = my_data[0];
// Initialize y
y=0;
do
{
// Check to see if we received a space char
dt_start = (*lcd_string - 32);
// Point to the start of the font data in the table
data_pointer = font_pointer;
// point to the data in the table for this font chars information
data_pointer += (dt_start * 4) + 7;
// get the font information
sFLASH_ReadBuffer(my_data,data_pointer,4);
h = my_data[0];
width = my_data[1];
l = my_data[2];
m = my_data[3];
// Find out where in the table the actual data is for this font char
data_start = (h << 16) | (m << 8) | l;
// Now point to the start of the actual data for this font char
data_pointer = font_pointer + data_start;
for(y_total=0;y_total<height;y_total++)
{
// Initialize the Mask bit for the data
mask = 0x01;
// Set new x,y location for LCD
GotoXY(ux,(uy + y));
// Tell LCD we are going to be sending data now
SPI_WriteCMD(0x2c);
po=0;
sFLASH_ReadBuffer(my_data,data_pointer,width);
// Bring CS pin low
PIN_MAP[SS].gpio_peripheral->BRR = PIN_MAP[SS].gpio_pin;
// Set or clear each pixel on the LCD in the x axis
for(x=0;x<width;x++)
{
// if pixel data then put dot on lcd
if(my_data[po] & mask)
{
SPI.transfer((uint8_t) (fcolor >> 8) );
SPI.transfer((uint8_t) fcolor );
}
else // else use background color
{
SPI.transfer((uint8_t) (bcolor >> 8) );
SPI.transfer((uint8_t) bcolor );
}
// Shift up one bit
mask<<=1;
// If we have done all 8 bits then reset back to 1
if(mask == 0x100)
{
mask=0x01;
// Also point to the next data byte
data_pointer++;
po++;
}
}
// This keeps the background color in-between chars
for(px=0;px<char_spacing;px++)
{
SPI.transfer((uint8_t) (bcolor >> 8) );
SPI.transfer((uint8_t) bcolor );
}
PIN_MAP[SS].gpio_peripheral->BSRR = PIN_MAP[SS].gpio_pin;
// whenever x winds up being the same as a byte size (I.E. 8,16,24,32,40...) then
// then the if(mask == 0x100) increments data_pointer on the exit
// when we dont want it to. so this backs it up if that was the case.
if(x % 8 != 0 )
{
// Set pointer for next data byte
data_pointer++;
}
// Move down one pixel the y axis
y++;
}
// Add the width of this font char + the user pixel spacing
ux += width + char_spacing;
// Thus char is done so reset the y counter
y=0;
// next character in string
lcd_string++;
}while(*lcd_string !='\0'); // keep spitting chars out until end of string
}
//******************************************************
//******************************************************
//******************************************************
void loop()
{
if(++seconds == 60)
{
seconds = 0;
if(++minutes==60)
{
minutes=0;
hours++;
}
}
sprintf(lcdstring,"%02u:%02u:%02u",hours,minutes,seconds);
// NVIC_DisableIRQ(CC3000_WIFI_INT_EXTI_IRQn);
LCD_Strings(lcdstring,0x80000,20,120,7,0xF4df,0x0000);
// NVIC_EnableIRQ(CC3000_WIFI_INT_EXTI_IRQn);
}