giaanthunder
Newbie level 2
im having trouble when compiling with mplab 9.65
if you have freetime. can you show me the way you fix these error.
my code
my error
---------- Post added at 01:53 ---------- Previous post was at 01:52 ----------
im using pic 16f877a
if you have freetime. can you show me the way you fix these error.
my code
Code:
#include <htc.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "lcd4x20.h"
#include <string.h>
__CONFIG(HS & WDTDIS & PWRTEN & UNPROTECT & BORDIS & LVPDIS);
#define _XTAL_FREQ 4000000
#define row0 RA0
#define row1 RA1
#define row2 RA2
#define row3 RA3
#define row4 RA4
#define row5 RA5
#define col0 RB0
#define col1 RB1
#define col2 RB2
#define col3 RB3
#define col4 RB4
#define col5 RB5
#define col6 RB6
#define col7 RB7
const char KEYS[6][8] = {
{"1","2","3","4","5","6","7","8"},
{"q","w","e","r","t","y","9","0"},
{"a","s","d","f","u","i","o","p"},
{"z","x","c","g","h","j","k","l"},
{"v","b","n","m",",",".","up","enter"},
{"shift","ctrl"," ","alt","clr","left","down","right"}
};
const char CAPS[6][8] = {
{"!","@","#","$","%","^","&","*"},
{"Q","W","E","R","T","Y","(",")"},
{"A","S","D","F","U","I","O","P"},
{"Z","X","C","G","H","J","K","L"},
{"V","B","N","M","<",">","up","enter"},
{"shift","ctrl"," ","alt","clr","left","down","right"}
};
#define kbd_debounce_factor 60
char dat_line1[] = "\0"; // Noi dung can hien thi - Hang 1.
char dat_line2[] = "\0"; // Noi dung can hien thi - Hang 2.
char dat_line3[] = "\0"; // Noi dung can hien thi - Hang 3.
char dat_line4[] = "\0"; // Noi dung can hien thi - Hang 4.
char chuoi_hien_thi[] = "\0" //noi dung can hien thi
bit ALL_ROWS(void)
{
if(row0 && row1 && row2 && row3 && row4 && row5)
return(0);
else
return(1);
}
void kbd_init()
{
ADCON1= 0b00000111;
TRISA= 0xFF;
PORTA= 0xFF;
TRISB= 0x00;
PORTB= 0xFF;
}
char kbd_getc() // Ham lay ma phim duoc nhan tren ban phim.
{
static bit kbd_down = 0; // Bien chi thi da co nhan hay chua co nhan phim lan nao (Mac dinh = FALSE).
char last_key[]; // Bien chua ma phim duoc nhan o lan nhan sau cung (Mac dinh = NULL).
unsigned char col = 0; // Bien thu tu cot duoc quet (Cot tich cuc, mac dinh = cot 0).
unsigned char row; // Bien thu tu hang co phim nhan (Hang tich cuc).
char kchar[]; // Bien chua ma phim.
unsigned char kbd_call_count; // Bien dem so lan goi quet phim de thuc hien chong doi.
kchar[] = "\0"; // Bien chua ma phim duoc nhan (Mac dinh ban dau chua ky tu NULL).
for(kbd_call_count = 0; kbd_call_count <= kbd_debounce_factor; kbd_call_count++) // Thuc hien vong lap de chong doi phim nhan.
{
switch(col)
{
case 0:
col7 = 1;
col6 = 1;
col5 = 1;
col4 = 1;
col3 = 1;
col2 = 1;
col1 = 1;
col0 = 0;
break;
case 1:
col7 = 1;
col6 = 1;
col5 = 1;
col4 = 1;
col3 = 1;
col2 = 1;
col1 = 0;
col0 = 1;
break;
case 2:
col7 = 1;
col6 = 1;
col5 = 1;
col4 = 1;
col3 = 1;
col2 = 0;
col1 = 1;
col0 = 1;
break;
case 3:
col7 = 1;
col6 = 1;
col5 = 1;
col4 = 1;
col3 = 0;
col2 = 1;
col1 = 1;
col0 = 1;
break;
case 4:
col7 = 1;
col6 = 1;
col5 = 1;
col4 = 0;
col3 = 1;
col2 = 1;
col1 = 1;
col0 = 1;
break;
case 5:
col7 = 1;
col6 = 1;
col5 = 0;
col4 = 1;
col3 = 1;
col2 = 1;
col1 = 1;
col0 = 1;
break;
case 6:
col7 = 1;
col6 = 0;
col5 = 1;
col4 = 1;
col3 = 1;
col2 = 1;
col1 = 1;
col0 = 1;
break;
case 7:
col7 = 0;
col6 = 1;
col5 = 1;
col4 = 1;
col3 = 1;
col2 = 1;
col1 = 1;
col0 = 1;
break;
}
if(kbd_down) // Kiem tra xac nhan viec da co nhan hay chua nhan phim.
// Neu chua nhan thi kiem tra phim nao se duoc nhan.
// Neu da co phim nhan thi cho den khi phim da nhan duoc nha (buong ra).
{ // Truong hop da co nhan phim (kbd_down = True) - Cho nha phim da nhan.
if(!ALL_ROWS()) // Neu khong co phim nao duoc nhan (khong con giu phim nhan nua).
{
kbd_down = 0; // Xac nhan khong con phim nao duoc nhan (kbd_down = False).
kchar = last_key; // Lay ma phim duoc nhan truoc do.
last_key = "\0"; // Cat ma phim (NULL) tuong ung khong nhan phim nao.
}
}
else
{ // Truong hop chua co phim nao nhan (kbd_down = False) - Kiem tra phim nao duoc nhan.
if(ALL_ROWS()) // Neu truong hop CO bat ky phim nao duoc nhan
{ // Kiem tra phim duoc nhan thuoc hang nao (Hang tich cuc).
if(!row0) // Hang 0 tich cuc? (row0 = LOW).
row = 0; // Hang 0.
else if(!row1) // Hang 1 tich cuc? (row1 = LOW).
row = 1; // Hang 1.
else if(!row2) // Hang 2 tich cuc? (row2 = LOW).
row = 2; // Hang 2.
else if(!row3) // Hang 3 tich cuc? (row3 = LOW).
row = 3; // Hang 3.
else if(!row4) // Hang 1 tich cuc? (row1 = LOW).
row = 4; // Hang 1.
else if(!row5) // Hang 2 tich cuc? (row2 = LOW).
row = 5; // Hang 2.
last_key = KEYS[row][col]; // Lay ma phim dua vao hang (row) va cot (col) tich cuc.
// Bo ma cua ban phim duoc thiet lap o dau chuong trinh.
kbd_down = 1; // Xac nhan da co phim nhan (kbd_down = True).
}
else // Neu truong hop KHONG CO phim nao duoc nhan.
{ // Chuyen sang quet cot ke tiep.
col++; // Tang bien quet cot -> chuyen sang quet cot ke tiep.
if (col == 8) // Xu ly de chi quet 4 cot (tra ve quet cot dau tien).
col = 0; // Cot 0.
}
}
}
while (ALL_ROWS()); // Cho cho den khi khong con giu phim nua moi tra ve ma phim nhan.
return(kchar); // Tra ve ma ASCII cua phim duoc nhan (bang ma duoc khai bao o dau chuong trinh).
}
void init_PORTC(void)
{
PORTC = 0X00;
TRISC = 0X00;
}
void init_PORTD(void)
{
PORTD = 0X00;
TRISD = 0X00;
}
void init_PORTE(void)
{
PORTE = 0X00;
TRISE = 0X00;
}
void main()
{
char k[]="\0";
init_PORTD();
PORTD = 0x00;
kbd_init();
while(1) // Vong lap cho ngat.
{
k = kbd_getc(); // Thuc hien quet ban phim va lay ma phim.
if(k!="\0") // Kiem tra co nhan phim (ma phim khac NULL).
{
strcpy(chuoi_hien_thi,k);
kbd_getc()="\0";
unsigned char i;
int len=strlen(chuoi_hien_thi);
if(len<61)
{
for(i=0;i<=19;i++)
dat_line1[i]=chuoi_hien_thi[i];
for(i=20;i<=39;i++)
dat_line2[i]=chuoi_hien_thi[i];
for(i=40;i<=58;i++)
dat_line3[i]=chuoi_hien_thi[i];
}
else
{
for(i=len-59;i<=len-38;i++)
dat_line1[i]=chuoi_hien_thi[i];
for(i=len-39;i<=len-18;i++)
dat_line2[i]=chuoi_hien_thi[i];
for(i=len-19;i<=len-1;i++)
dat_line3[i]=chuoi_hien_thi[i];
}
lcd_puts("\f"); // Xoa man hinh LCD.
for(i=0;i<=19;i++)
{
lcd_gotoxy(i,0); // Xac dinh toa do hien thi cho hang 1.
lcd_putc(dat_line1[i]); // Lay ky tu hien thi tu chuoi 1 dua len C.LCD.
lcd_gotoxy(i,1); // Xac dinh toa do hien thi cho hang 2.
lcd_putc(dat_line2[i]); // Lay ky tu hien thi tu chuoi 2 dua len C.LCD.
lcd_gotoxy(i,2); // Xac dinh toa do hien thi cho hang 3.
lcd_putc(dat_line3[i]); // Lay ky tu hien thi tu chuoi 3 dua len C.LCD.
lcd_gotoxy(i,3); // Xac dinh toa do hien thi cho hang 4.
lcd_putc(dat_line4[i]); // Lay ky tu hien thi tu chuoi 4 dua len C.LCD.
}
}
}
}
my error
Executing: "C:\Program Files\HI-TECH Software\PICC\PRO\9.65\bin\picc.exe" --pass1 C:\Users\giaanthunder\Desktop\keypad\D1.c -q --chip=16F877A -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"
Error [316] C:\Users\giaanthunder\Desktop\keypad\D1.c; 29.6 "}" expected
Error [316] C:\Users\giaanthunder\Desktop\keypad\D1.c; 29.6 "}" expected
Error [241] C:\Users\giaanthunder\Desktop\keypad\D1.c; 29.6 initialization syntax
Error [316] C:\Users\giaanthunder\Desktop\keypad\D1.c; 37.6 "}" expected
Error [316] C:\Users\giaanthunder\Desktop\keypad\D1.c; 37.6 "}" expected
Error [241] C:\Users\giaanthunder\Desktop\keypad\D1.c; 37.6 initialization syntax
Error [314] C:\Users\giaanthunder\Desktop\keypad\D1.c; 55.1 ";" expected
Error [285] C:\Users\giaanthunder\Desktop\keypad\D1.c; 59.1 no identifier in declaration
Warning [374] C:\Users\giaanthunder\Desktop\keypad\D1.c; 59.1 missing basic type; int assumed
Error [314] C:\Users\giaanthunder\Desktop\keypad\D1.c; 59.1 ";" expected
Error [285] C:\Users\giaanthunder\Desktop\keypad\D1.c; 61.1 no identifier in declaration
Warning [374] C:\Users\giaanthunder\Desktop\keypad\D1.c; 61.1 missing basic type; int assumed
Error [314] C:\Users\giaanthunder\Desktop\keypad\D1.c; 61.1 ";" expected
Error [195] C:\Users\giaanthunder\Desktop\keypad\D1.c; 81.7 expression syntax
Warning [361] C:\Users\giaanthunder\Desktop\keypad\D1.c; 173.5 function declared implicit int
Error [202] C:\Users\giaanthunder\Desktop\keypad\D1.c; 176.17 only lvalues may be assigned to or modified
Error [202] C:\Users\giaanthunder\Desktop\keypad\D1.c; 177.16 only lvalues may be assigned to or modified
Warning [359] C:\Users\giaanthunder\Desktop\keypad\D1.c; 177.16 illegal conversion between pointer types
Error [202] C:\Users\giaanthunder\Desktop\keypad\D1.c; 198.26 only lvalues may be assigned to or modified
Warning [357] C:\Users\giaanthunder\Desktop\keypad\D1.c; 198.26 illegal conversion of integer to pointer
Warning [365] C:\Users\giaanthunder\Desktop\keypad\D1.c; 211.14 pointer to non-static object returned
Warning [358] C:\Users\giaanthunder\Desktop\keypad\D1.c; 211.14 illegal conversion of pointer to integer
Error [202] C:\Users\giaanthunder\Desktop\keypad\D1.c; 243.15 only lvalues may be assigned to or modified
Warning [357] C:\Users\giaanthunder\Desktop\keypad\D1.c; 243.15 illegal conversion of integer to pointer
Error [202] C:\Users\giaanthunder\Desktop\keypad\D1.c; 247.16 only lvalues may be assigned to or modified
Warning [358] C:\Users\giaanthunder\Desktop\keypad\D1.c; 247.16 illegal conversion of pointer to integer
---------- Post added at 01:53 ---------- Previous post was at 01:52 ----------
im using pic 16f877a
Last edited by a moderator: