Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
int a= 234;
unsigned char buffer[10];
itoa( a, buffer,10);
after that where to add display??Example
buffer will now hold "123" as a string to be printed..C:int a= 234; unsigned char buffer[10]; itoa( a, buffer,10);
#include <htc.h>
#include <stdlib.h>
__CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
#define DAD PORTB
#define RST RC5
#define CLK RC3
#define DATA RC4
extern const char Font2[];
void blit(char a), clear(void);
unsigned char leds[30];
unsigned char buffer[30];
unsigned char pow[] = {0,128,64,32,16,8,4,2,1};
display(char *str);
int data( int p);
int t,r;
char b,e,v;
main (){
TRISC=0B00000000;
TRISB=0B00000000;
while(1){
clear();
display(" Led ");
blit(1);
int t=234;
unsigned char buffe[10];
itoa( t, buffe,10);
display(buffe);
blit(1);
}
}
display(char *str)
{
int addr;
int z;
while(*str!=0){
addr = ((int)*str++ - 0x20);
addr *= 5;
int y=0;
for(z=0;z<5;z++){
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
int y=0;
for(z=6;z<11;z++){
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
int y=0;
for(z=12;z<17;z++){
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
int y=0;
for(z=18;z<23;z++){
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
int y=0;
for(z=24;z<29;z++){
leds[z] = Font2[addr+y];
y++;
}
void blit(char a){
for(char x=0;x<40;x++){
for(char x=0;x<5;x++){
char u=-1;
b=0b00000001;
for(int r=0;r<8;r++){
DAD=pow[r];
__delay_ms(2);
RST=0;
RST=1;
u++;
for(int a=0;a<32;a++){
DAD=0;
RST=1;
char t,n;
n=leds[a];
n>>=u;
t=(n & b);
DATA=t;
CLK=1;
__delay_us(10);
CLK=0;
}}
}
{
if(a==1){
for(char x=0;x<32;x++){
//leds[x]>>=1;
}
}
if(a==3){
for(char x=0;x<32;x++){
leds[x]<<=1;
}
}
if(a==0){
for(char x=0;x<32;x++){
leds[x]=leds[x+1];
}
}
}
}
}
void clear(void){
for(char x=0;x<30;x++){
leds[x]=0;
}
}
Hello again,The warning is because I think the itoa() needs a reference.. ie.. itoa( a, &buffer[0],10);
The errors are your code doesn't fit inside the pic.... Which pic are you using???
The display routine takes a char pointer to ram not rom... With Hi-tech a rom pointer has to use the const tag...It looks like display needs a rom pointer. See if there is a display that takes a ram pointer or a function that prints 1 character.
Mike.
uild C:\Users\abc\Documents\mplab\scrolling.C for device 16F72
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe
Make: The target "C:\Users\abc\Documents\mplab\scrolling.p1" is up to date.
Make Error: Can't open file "\". (3)
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\abc\Documents\mplab\Font.C -q --chip=16F72 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" -oscrolling.C.cof -mscrolling.C.map --summary=default --output=default scrolling.p1 Font.p1 --chip=16F72 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.83
Copyright (C) 2011 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error [1347] ; 0. can't find 0x2A words (0x2a withtotal) for psect "text186" in class "CODE" (largest unused contiguous range 0x1C)
Error [1347] ; 0. can't find 0x21 words (0x21 withtotal) for psect "cinit" in class "CODE" (largest unused contiguous range 0x1C)
Error [1347] ; 0. can't find 0x8 words (0x8 withtotal) for psect "clrtext" in class "CODE" (largest unused contiguous range 0x2)
********** Build failed! **********
#include <htc.h>
#include <stdlib.h>
#include <string.h>
__CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
#define DAD PORTB
#define RST RC5
#define CLK RC3
#define DATA RC4
extern const char Font2[];
void blit(char a), clear(void);
unsigned char leds[30];
unsigned char buffer[30];
unsigned char pow[] = {0,128,64,32,16,8,4,2,1};
void display(char *str), blit(char a);
int data( int p);
char b;
main ()
{
int t=234;
TRISC=0B00000000;
TRISB=0B00000000;
while(1){
clear();
strcpy(buffer," Led ");
display(buffer);
blit(1);
itoa( t, &buffer[0], 10);
display(buffer);
blit(1);
}
}
void display(char *str)
{
int addr;
int z,y;
while(*str!=0)
{
addr = ((int)*str++ - 0x20);
addr *= 5;
y=0;
for(z=0;z<5;z++)
{
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
y=0;
for(z=6;z<11;z++)
{
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
y=0;
for(z=12;z<17;z++)
{
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
y=0;
for(z=18;z<23;z++)
{
leds[z] = Font2[addr+y];
y++;
}
addr = ((int)*str++ - 0x20);
addr *= 5;
y=0;
for(z=24;z<29;z++)
{
leds[z] = Font2[addr+y];
y++;
}
}
}
void blit(char a)
{
char x,u,t,r,n;
for(x=0;x<40;x++)
{
for(x=0;x<5;x++)
{
u=-1;
b=0b00000001;
for(r=0;r<8;r++)
{
DAD=pow[r];
__delay_ms(2);
RST=0;
RST=1;
u++;
for(a=0;a<32;a++)
{
DAD=0;
RST=1;
n=leds[a];
n >>= u;
t=(n & b);
DATA=t;
CLK=1;
__delay_us(10);
CLK=0;
}
}
}
}
if(a==1)
{
for(x=0;x<32;x++)
//leds[x]>>=1;
if(a==3)
{
for( x=0;x<32;x++)
leds[x]<<=1;
if(a==0)
{
for(x=0;x<32;x++)
leds[x]=leds[x+1];
}
}
}
}
void clear(void)
{
for(char x=0;x<30;x++)
leds[x]=0;
}