CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Upload custom character to MAX7456 chip

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pic_micro



Joined: 07 Feb 2011
Posts: 26

View user's profile Send private message

Upload custom character to MAX7456 chip
PostPosted: Thu Apr 21, 2011 10:14 pm     Reply with quote

I used the MAX7456 dev kit GUI to create custom character, after I save it into *.MCM file, I open with notepad and there is 16385 lines, here are some of the top lines
MAX7456
1010101
1010101
1010101
1010101
1010101
1010101
1010101
1010101
1010101
1010101
1010101
.
.
.
to 16385 lines total.

How can I upload these to the MAX7456 chip?

I follow John Geek links http://www.john.geek.nz/2011/01/adding-custom-characters-to-the-max7456-video-overlay-generator/

But according to his, there will be only 54 lines to upload (0-53). I not sure what to do. Can anybody help?

Remember, I build my own board (breadboard) according to SparkFun schematic, so there is no way I can access the chip as describe per Maxim kits through Serial or USB.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 22, 2011 6:07 am     Reply with quote

John's article clearly details how to create and upload the custom characters.Simple and easy.His code can be converted to CCS C in a few minutes.
So how does your PIC communicate with the MAX7456 if not through SPI ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19518

View user's profile Send private message

PostPosted: Fri Apr 22, 2011 8:56 am     Reply with quote

To emphasise the point, look at the chip's data sheet. It's _only_ interface, is SPI. Serial peripheral interface. The demo boards allowing you to access the chip using other interfaces, have a processor like the PIC, receiving data from USB or RS232, and then talking to the chip. Exactly what you can do with a PIC.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 22, 2011 1:32 pm     Reply with quote

Quote:
How can I upload these to the MAX7456 chip?

You gave up on your other MAX7456 thread, here:
http://www.ccsinfo.com/forum/viewtopic.php?t=45241
Did you ever do the test to see if you can read back the same byte that
you wrote to the chip ? You need to do that before you try anything else.

With regard to the John Geek link, he's using "spi_send_byte()" to send
the data to the MAX7456. That's equivalent to the max7456_write()
function, shown in the code below.

To do the communication test with the MAX7456, connect your PIC to the
Max7456 like this:
Code:

PIC   Max7456
SDO   SDIN
SDI   SDOUT
SCLK  SCLK
\CS   \CS   

Use pin C2 on the PIC for \CS.

Then run this program. It should hopefully say that it read "55" from
the MAX7456:
Code:

#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

// SPI mode definitions.
#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

#define MAX7456_CS  PIN_C2


//-------------------------------------
// Write to the specified register.

void max7456_write(int8 reg_addr, int8 data)
{
output_low(MAX7456_CS);
spi_write(reg_addr);
spi_write(data);
output_high(MAX7456_CS);
}

//------------------------------------
// Read the specified register.

int8 max7456_read(int8 reg_addr)
{
int8 retval;

output_low(MAX7456_CS);
spi_write(reg_addr | 0x80);  // Set top bit to do a Read operation
retval = spi_read(0);
output_high(MAX7456_CS);

return(retval);
}


//======================================
void main()
{
int8 result;

// Initialize the PIC's SPI module.
setup_spi(SPI_MASTER|SPI_MODE_0|SPI_CLK_DIV_4);
output_high(MAX7456_CS);
delay_ms(100);   // Minimum power-up delay is 50 ms

max7456_write(0, 0x55);  // Write 0x55 to register 0
result = max7456_read(0);  // Read register 0

// Display what we read.
printf("Wrote 0x55, read: %X \n\r", result);

while(1);
}
pic_micro



Joined: 07 Feb 2011
Posts: 26

View user's profile Send private message

MAX7456 GRAPHIC
PostPosted: Thu Apr 28, 2011 9:49 am     Reply with quote

I got it working by using SPI function like you mentioned earlier. I can send characters to MAX7456 and display it OK.

I am trying to display clock ( HH:MM:SS or 12:59:59 on the the screen (number 0-9 only, no character), but I can't figure out how to convert hex to decimal to display on the screen. When I increment the SEC, MIN, HOUR, they are in hex format not decimal, example e.g instead of hex 0x0A, 0x0B .... 0x3F , I want 10, 11, .... 59 to display

I have int SEC, MIN, HOUR; and I also define location to display char xSEC, xMIN, xHOUR.

I use timer1 interrupt and start increase SEC, MIN, HOUR

if SEC >= 59, reset SEC = 0 and increment MIN, if MIN >= 59, reset MIN = 0 and increment HOUR, and etc.

What is the best way to convert HEX to DEC? is there any sample code to handle this?

below are my code:

max.c (main)
Code:
#include <16f877a.h>
#fuses XT, NOWDT, NOPROTECT, NOBROWNOUT,  NOPUT, NOLVP
#use delay(clock=4000000)

/************************
   connection
   PIC  |   MAX7456
   ----------------
   16    |   11   - C4
   15    |   9   - C5
   14    |   10   - C3
       |   8   - A1

**************************/


#include <driver.c>
#include <interrupts.c>



void main()
{
   max7456_init();
   
   max7456_write(0x00, 0x02);

   setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);
   
   while(1)
   {
   
   }
   
}


driver.c
Code:
#define MAX7456_CS     PIN_A1
#define MAX7456_CLK     PIN_C3
#define MAX7456_DI     PIN_C5
#define MAX7456_DO      PIN_C4


char x = 0;

void max7456_write(int8 addr, int8 data)
{
   output_low(MAX7456_CS);
   spi_write(addr);
   spi_write(data);
   output_high(MAX7456_CS);
   delay_ms(1);
}

//============= Disable ========================
void Disable(void)      // Disable
{
   max7456_write(0x00, 0x00);
}


//============= Enable =======================
void Enable(void)
{
   max7456_write(0x00, 0x08);   // Enable NTSC
   max7456_write(0x04, 0x40);
}


//============= Enable =======================
void max7456_init(void)
{
   short int i;
   output_low(MAX7456_DI);
   output_low(MAX7456_CLK);
   output_high(MAX7456_CS);
   i=input(MAX7456_DO);

   setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16);
   
}


void lines(void)
{
   
   enable();

   // =========LINE1 ============
   x = 1;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x01);
   delay_ms(10);

   // =========LINE2 ============
   x = 31;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x02);
   delay_ms(10);

   // =========LINE3 ============
   x = 61;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x03);
   delay_ms(10);

   // =========LINE4 ============
   x = 91;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x04);
   delay_ms(10);

   // =========LINE5 ============
   x = 121;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x05);
   delay_ms(10);

   // =========LINE6 ============
   x = 151;
   max7456_write(0x06, x);
   max7456_write(0x07, 0x06);
   delay_ms(10);
}

interrupts.c
Code:
int counter = 0;
int MIN = 0;
int SEC = 0;
int HOUR = 0;

char xHour = 40;
char xMIN =  45;
char xSEC = 50;

void display(void)
{

   max7456_write(0x06, xHOUR);
   max7456_write(0x07, HOUR);
   delay_ms(1);
   

   max7456_write(0x06, xMIN);
   max7456_write(0x07, MIN);
   delay_ms(1);

   max7456_write(0x06, xSEC);
   max7456_write(0x07, SEC);
   delay_ms(1);

   
   }
   

   
}
   
   

#INT_TIMER1
timer1_isr()
{
   clear_interrupt(INT_TIMER1);
   counter++;
   enable();
         
   

   if(counter >=10)
   {
         
         
      SEC++;
      if(SEC >= 0x3B)  // decimal 59
      {
         SEC = 0;
         MIN++;
         if(MIN >= 0x3B)  // decimal 59
         {
            HOUR++;
            if(HOUR >= 0x0C)  // decimal 12
            {
               HOUR = 0;
            }
         }
      }
      display();
      
      
   }
   
}




#INT_EXT
void ext_ISR(void)
{
   // clear screen
//   clear_interrupt(INT_EXT);
   
   max7456_write(0x00, 0x02);
   delay_ms(20);
   
   
}


If anyone can help me out, I would be appreciate
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 28, 2011 11:08 am     Reply with quote

Clock numbers are displayed in BCD format. You need a routine to
convert your byte integers to BCD. Here it is:
Code:

//----------------------------------------------
// This function converts an 8 bit binary value
// to an 8 bit BCD value.
// The input range must be from 0 to 99.

int8 bin2bcd(int8 value)
{
char retval;

retval = 0;

while(1)
  {
   // Get the tens digit by doing multiple subtraction
   // of 10 from the binary value.
   if(value >= 10)
     {
      value -= 10;
      retval += 0x10;
     }
   else // Get the ones digit by adding the remainder.
     {
      retval += value;
      break;
     }
   }

return(retval);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group