simple usart programming problem

Thread Starter

kuannygohcheetatt

Joined Oct 31, 2013
61
Rich (BB code):
//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! **********
 
Last edited by a moderator:

t06afre

Joined May 11, 2009
5,934
You have build failed. So a hex file will most probably not be generated.
Also what is this number __CONFIG(0x3f31); It may be correct but it does not tell me much. If your techer allow this he/she should get a smack on fingers ;)
 

Ian Rogers

Joined Dec 12, 2012
1,136
I see a main file mini project.c and a usart.c but I don't see the lcd.c or the delay.c

Make sure these files are in the project directory.... ( They aren't the built in ones )

Otherwise If you downloaded this code... Download the rest!!
 

spinnaker

Joined Oct 29, 2009
7,830
I don't see any error message. I never used Hi-tech, and now I'm glad that I haven't.

I thought it was just me. I thought maybe they were buried in the lines below all of those warnings. But I am not seeing any.

I don't see how a clean could cause a build to fail.
 

JohnInTX

Joined Jun 26, 2012
4,787
I don't see any error message. I never used Hi-tech, and now I'm glad that I haven't.
I don't see an error message either and I'm wondering if the OP is using Win7? On Win7-64 Pro, my earlier Hitech PICC-18 doesn't display the errors...

All of the 'Clean' stuff can be ignored. On a full build it wants to delete all but the source files. If the project hasn't been successfully built before, these files won't exist.

The first two 'Executing' lines compile mini project.c and usart.c. The last one is the linker.

You might want to check out the Project Build properties tabs to see if you can get it to a more verbose mode re: errors. I could not get it to on my version.. You also might look for a .err file for the compile/link phases to shed some light.

Or use XC8.

For the OP, have you abandoned this thread?
 
Last edited:
Top