//Laboratory No:1
//File name:Lab1.c
//Student Name:Goh Chee Tatt
#define XTAL_FREQ 4MHZ
#include <htc.h>
#include "delay.h"
#include "lcd.h"
#include "usart.h"
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 4000000
/*Lab1.c - Turn ON PORT B 0 LED*/
__CONFIG(0x3f31);
unsigned long int i;
delay1s()
{
for(i=0;i<30000;i++)
{
NOP(); //no operation is carried out
}
}
main()
{
TRISA = 0;
TRISB = 0b00001000;
TRISC = TRISD = 0;
PORTA = PORTB = PORTC = PORTD = 0;
//ADC OFF
ADCON0 = 0;
ADCON1 = 0b110;
//control bytes for usart( Bluetooth )
SPBRG = 25; //4MHz
TXSTA = 0x24;
RCSTA = 0x90;
//USART interrupt
RCIE = 1;
GIE = 1;
PEIE = 1;
while(1)
{
PORTB=0x01; //set pin0 of portb as high
delay1s();
lcd_goto(1,1);
PORTB=0x00; //set pin0 of portb as high
TXREG = 'A';
}
}
void interrupt usart(void) {
if ( RCIE && RCIF )
{
switch( RCREG )
{
case 'A' :
lcd_puts("hello");
break;
}
}
}
i am trying to send data from my tx pin to my rx pin, i cant see any problem with this program however it fails to run.
this is my error message
Clean: Deleting intermediary and output files.
Clean Warning: Can't delete file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project.p1" from disk. (32)
Clean: Deleted file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\usart.p1".
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.cof" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.hex" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.sym" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.map" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.hxl" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\startup.lst" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\startup.rlf" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\doprnt.p1" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\doprnt.pre" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.obj" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.lst" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.rlf" doesn't exist.
Clean Warning: Can't delete file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.sdb" from disk. (32)
Clean: Deleted file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.mcs".
Clean: Done.
Build C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1 for device 16F877A
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" --pass1 "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project.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"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" --pass1 "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\usart.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"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" "-omini project1.cof" "-mmini project1.map" --summary=default --output=default "mini project.p1" usart.p1 --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"
(1273) Omniscient Code Generation not available in Lite mode (warning)
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.70
Copyright (C) 2009 Microchip Technology Inc.
********** Build failed! **********
//File name:Lab1.c
//Student Name:Goh Chee Tatt
#define XTAL_FREQ 4MHZ
#include <htc.h>
#include "delay.h"
#include "lcd.h"
#include "usart.h"
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 4000000
/*Lab1.c - Turn ON PORT B 0 LED*/
__CONFIG(0x3f31);
unsigned long int i;
delay1s()
{
for(i=0;i<30000;i++)
{
NOP(); //no operation is carried out
}
}
main()
{
TRISA = 0;
TRISB = 0b00001000;
TRISC = TRISD = 0;
PORTA = PORTB = PORTC = PORTD = 0;
//ADC OFF
ADCON0 = 0;
ADCON1 = 0b110;
//control bytes for usart( Bluetooth )
SPBRG = 25; //4MHz
TXSTA = 0x24;
RCSTA = 0x90;
//USART interrupt
RCIE = 1;
GIE = 1;
PEIE = 1;
while(1)
{
PORTB=0x01; //set pin0 of portb as high
delay1s();
lcd_goto(1,1);
PORTB=0x00; //set pin0 of portb as high
TXREG = 'A';
}
}
void interrupt usart(void) {
if ( RCIE && RCIF )
{
switch( RCREG )
{
case 'A' :
lcd_puts("hello");
break;
}
}
}
i am trying to send data from my tx pin to my rx pin, i cant see any problem with this program however it fails to run.
this is my error message
Clean: Deleting intermediary and output files.
Clean Warning: Can't delete file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project.p1" from disk. (32)
Clean: Deleted file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\usart.p1".
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.cof" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.hex" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.sym" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.map" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.hxl" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\startup.lst" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\startup.rlf" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\doprnt.p1" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\doprnt.pre" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.obj" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.lst" doesn't exist.
Clean Warning: File "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.rlf" doesn't exist.
Clean Warning: Can't delete file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.sdb" from disk. (32)
Clean: Deleted file "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1.mcs".
Clean: Done.
Build C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project1 for device 16F877A
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" --pass1 "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\mini project.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"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" --pass1 "C:\Users\user\Desktop\engineering degree\Eng 2018M\lab1\usart.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"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.70\bin\picc.exe" "-omini project1.cof" "-mmini project1.map" --summary=default --output=default "mini project.p1" usart.p1 --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"
(1273) Omniscient Code Generation not available in Lite mode (warning)
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.70
Copyright (C) 2009 Microchip Technology Inc.
********** Build failed! **********