display large number
Posted: Mon Apr 03, 2006 1:37 pm
Hi,
I'm using the Atmega32 uC to send characters to the LK204-25 LCD. I can
send individual characters (e.g. 'A' , 'B' , '1' '7', etc); I can also display a large number
such as '11500' by send one number at a time with a function call. (USART_TRANSMIT).
The problem arises when I want to send a large number such as '11500' but
with just
one function call. Does anybody have any suggestions as to how to do this?
Thanks in advance
I'm using the following code to send characters:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
unsigned char txbuffer[];
long int txbuffer_numbers[10];
void USART_Transmit( unsigned char data);
void USART_Transmit_Set_Cursor_Position(void);
void USART_Transmit_Clear_Screen(void);
void USART_Transmit_Number(void);
void delay_ms(unsigned short ms);
int main (void)
{
UCSRA=0x02;
UCSRB=0x08;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
USART_Transmit_Clear_Screen();
USART_Transmit_Number();
}
void USART_Transmit_Clear_Screen(void)
{
int x;
txbuffer[0] = 254;
txbuffer[1] = 88;
for (x=0; x<2; x++)
{
USART_Transmit(txbuffer[x]);
}
}
void USART_Transmit_Set_Cursor_Position(void)
{
int k;
txbuffer[0] = 254;
txbuffer[1] = 71;
txbuffer[2] = 4;
txbuffer[3] = 3;
for (k=0; k<4; k++)
{
USART_Transmit(txbuffer[k]);
}
}
void USART_Transmit( unsigned char data)
{
// Wait for empty buffer
while ( !( UCSRA & (1<<UDRE)) )
;
// Put data into buffer, sends the data
UDR = data;
}
void USART_Transmit_Number(void)
{
USART_Transmit_Set_Cursor_Position();
txbuffer_numbers[0] = '11500';
USART_Transmit(txbuffer_numbers[0]);
}
I'm using the Atmega32 uC to send characters to the LK204-25 LCD. I can
send individual characters (e.g. 'A' , 'B' , '1' '7', etc); I can also display a large number
such as '11500' by send one number at a time with a function call. (USART_TRANSMIT).
The problem arises when I want to send a large number such as '11500' but
with just
one function call. Does anybody have any suggestions as to how to do this?
Thanks in advance
I'm using the following code to send characters:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
unsigned char txbuffer[];
long int txbuffer_numbers[10];
void USART_Transmit( unsigned char data);
void USART_Transmit_Set_Cursor_Position(void);
void USART_Transmit_Clear_Screen(void);
void USART_Transmit_Number(void);
void delay_ms(unsigned short ms);
int main (void)
{
UCSRA=0x02;
UCSRB=0x08;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
USART_Transmit_Clear_Screen();
USART_Transmit_Number();
}
void USART_Transmit_Clear_Screen(void)
{
int x;
txbuffer[0] = 254;
txbuffer[1] = 88;
for (x=0; x<2; x++)
{
USART_Transmit(txbuffer[x]);
}
}
void USART_Transmit_Set_Cursor_Position(void)
{
int k;
txbuffer[0] = 254;
txbuffer[1] = 71;
txbuffer[2] = 4;
txbuffer[3] = 3;
for (k=0; k<4; k++)
{
USART_Transmit(txbuffer[k]);
}
}
void USART_Transmit( unsigned char data)
{
// Wait for empty buffer
while ( !( UCSRA & (1<<UDRE)) )
;
// Put data into buffer, sends the data
UDR = data;
}
void USART_Transmit_Number(void)
{
USART_Transmit_Set_Cursor_Position();
txbuffer_numbers[0] = '11500';
USART_Transmit(txbuffer_numbers[0]);
}