Code for testing

Questions and discussions are relating to using current firmware.

gabyramos
Posts: 3
Joined: Wed Jul 04, 2007 7:17 pm

Code for testing

Post by gabyramos »

Hi,
I am using F-51852 Optrex display,
Do you have an easy code that i can prove in my application?
I want to know if my hardware is right connected, because i can't see the pixels on.

Thanks



User avatar
vivat
Site Admin
Posts: 70
Joined: Sun Nov 28, 2004 5:24 pm
First Name: Nick
Last Name: G.
Location: USA
Contact:

Post by vivat »

Please provide me with more information so I can better assist you. What controller are you using with your F-51852 display? What microcontroller are you using in your application?


Support Group,
TVI Electronics

gabyramos
Posts: 3
Joined: Wed Jul 04, 2007 7:17 pm

Post by gabyramos »

I'm using F-51852GNBJ with a NJU6676 controller and i'm running my application in a MSP430 (Texas Instruments microController).
My main problem is that I can not display my data in the screen.
Thanks for your attention

GabyRamos



User avatar
vivat
Site Admin
Posts: 70
Joined: Sun Nov 28, 2004 5:24 pm
First Name: Nick
Last Name: G.
Location: USA
Contact:

Post by vivat »

I'm not familiar with the MSP430. In our TC553/852 controller we utilize the Atmega16 MCU. You need to make sure your VCC for LCD is 5V. Also make sure you use the proper initialization sequence for your display.


Support Group,
TVI Electronics

bmhill

Sample Code for the TC553/852

Post by bmhill »

I have a TC553/852 and am using an ATMega16 and wanted to know if you have any sample code to test the LCD with the micro?



User avatar
vivat
Site Admin
Posts: 70
Joined: Sun Nov 28, 2004 5:24 pm
First Name: Nick
Last Name: G.
Location: USA
Contact:

Re: Code for testing

Post by vivat »

Below are some code snippets that can be used in order to test your LCD with the TC553/852 controller and Atmega16 micro. Make sure you connect RxD and TxD from TC553/852 controller to TxD and RxD on Atmega16 and use a common ground (GND). For a connection diagram refer to the most up-to-date TC553/852 Controller User Manual.

Code: Select all

/* uart_rx is a global 
use interrupt handler to update 
example    

#pragma interrupt_handler uart0_rx_isr:12 
void uart0_rx_isr(void) 
{ 
 //uart has received a character in UDR 
 uart_rx = getchar(); 
} 

don't forget to set up UART 
*/ 

// ***************************************************************************** 
void wait_for_response(void) 
{ 
 uart_rx = 0; 
 while(uart_rx == 0); 
} 
// ***************************************************************************** 
void clear_screen(void) 
{ 
 printf("%c",1); // clear screen 
 printf("%c",1); // clear screen 
 wait_for_response(); 
} 
// ***************************************************************************** 
void start_p_c(char page, char column) 
{ 
 printf("%c",6); // start page 
 printf("%c",page); // page number 
 printf("%c",18); // start column 
 printf("%c",column); // column number 
 wait_for_response(); 
} 
// ***************************************************************************** 
void line_draw(char start_x, char start_y, char stop_x, char stop_y) 
{ 
 printf("%c",30); //  line 
 printf("%c",0); // draw 
 printf("%c",start_x); // start x 
 printf("%c",start_y); // start y 
 printf("%c",stop_x); // stop x 
 printf("%c",stop_y); // stop y 
 wait_for_response(); 
} 
// ***************************************************************************** 
void rectangle_draw(char rectangle, char start_x, char start_y, char stop_x, char stop_y) 
{ 
 printf("%c",30); //  rectangle 
 printf("%c",rectangle); // draw 
 printf("%c",start_x); // start x 
 printf("%c",start_y); // start y 
 printf("%c",stop_x); // stop x 
 printf("%c",stop_y); // stop y 
 wait_for_response(); 
} 
// ***************************************************************************** 
void font_select(char font) 
{ 
 printf("%c",21); //  font select 
 printf("%c",font); //  font 
 wait_for_response(); 
} 
// ***************************************************************************** 
void print_font(char font) 
{ 
 printf("%c",2); //  text mode 
 printf("%c",font); //  font 
 wait_for_response(); 
} 
// ***************************************************************************** 
void hello(void) 
{ 
 char message[5]= {'H','e','l','l','o'}; 
 char i; 
 int k; 
 for(i=0;i<5;i++) 
   { 
    print_font(message[i]); 
   for(k=0;k<3000;k++); //delay 
   }  
} 
// ***************************************************************************** 
void main(void) 
{ 
 init_devices(); 
 uart_rx = 0; 
 clear_screen(); 
 line_draw(62,0,62,63); //line from 62,0 to 62,63 
 line_draw(63,0,63,63); //line from 63,0 to 63,63 
 line_draw(0,31,127,31); //line from 0,31 to 127,31 
 font_select(1); // 1 for font 5x7, 2 for font 8x14, 3 for font 8x14 Bold 
 start_p_c(1,5); // page,column 
 hello(); 
 font_select(2); // 1 for font 5x7, 2 for font 8x14, 3 for font 8x14 Bold 
 start_p_c(1,70); // page,column 
 hello(); 
 font_select(3); // 1 for font 5x7, 2 for font 8x14, 3 for font 8x14 Bold 
 start_p_c(5,5); // page,column 
 hello(); 
 start_p_c(5,70); // page,column 
 hello(); 
 rectangle_draw(3, 69, 40, 101, 55);// box, start_x, start_y, stop_x, stop_y 
}


Support Group,
TVI Electronics

bmhill

sample code issue

Post by bmhill »

I was testing the sample code but when I try to compile the code the #pragma interrupt is not recognized and I was wondering if there is another way in which this command can work or if you know how to make this work with the ATMega16 on codevisionAVR



User avatar
vivat
Site Admin
Posts: 70
Joined: Sun Nov 28, 2004 5:24 pm
First Name: Nick
Last Name: G.
Location: USA
Contact:

Re: Code for testing

Post by vivat »

The code above assumes that all peripherals have been initialized. Below is an example of initialization of the Atmega16 UART and its PORTs. You might need to change the header (include) files according to your compiler. Typically, header files are included via compiler directives at the beginning of the source file. A precompiled header file will be searched for when #include is seen in the compilation.

Code: Select all

#include <mega16.h> 
#include <stdio.h> 

char uart_rx; 

void port_init(void) 
{ 
 PORTA = 0xFF; 
 DDRA  = 0xFF; 
 PORTB = 0xFF; 
 DDRB  = 0xFF; 
 PORTC = 0xFF; 
 DDRC  = 0xFF; 
 PORTD = 0xFF; 
 DDRD  = 0xFF; 
} 

//UART0 initialize 
// desired baud rate: 9600 
// actual: baud rate:9600 (0.0%) 
// char size: 8 bit 
// parity: Disabled 
void uart0_init(void) 
{ 
 UCSRB = 0x00; //disable while setting baud rate 
 UCSRA = 0x00; 
 UCSRC = 0x06; 
 UBRRL = 0x3B; //set baud rate lo 
 UBRRH = 0x00; //set baud rate hi 
 UCSRB = 0xD8; 
} 

#pragma interrupt_handler uart0_rx_isr:12 
void uart0_rx_isr(void) 
{ 
 //uart has received a character in UDR 
 uart_rx = getchar(); 
} 

#pragma interrupt_handler uart0_tx_isr:14 
void uart0_tx_isr(void) 
{ 
 //character has been transmitted 
} 

//call this routine to initialize all peripherals 
void init_devices(void) 
{ 
 //stop errant interrupts until set up 
 CLI(); //disable all interrupts 
 port_init(); 
 uart0_init(); 
 MCUCR = 0x00; 
 GICR  = 0x00; 
 TIMSK = 0x00; //timer interrupt sources 
 SEI(); //re-enable interrupts 
 //all peripherals are now initialized 
}


Support Group,
TVI Electronics

Post Reply