simple usart programming problem

Discussion in 'Embedded Systems and Microcontrollers' started by kuannygohcheetatt, Jan 30, 2014.

  1. kuannygohcheetatt

    Thread Starter Member

    Oct 31, 2013
    61
    0
    Code ( (Unknown Language)):
    1.  
    2. [B]//Laboratory No:1
    3. //File name:Lab1.c
    4. //Student Name:Goh Chee Tatt
    5.  
    6. #define XTAL_FREQ 4MHZ
    7.  
    8.  
    9. #include <htc.h>
    10. #include "delay.h"
    11. #include "lcd.h"
    12. #include "usart.h"
    13.  
    14. #include <stdio.h>
    15. #include <stdlib.h>
    16.  
    17.  
    18. #define _XTAL_FREQ 4000000
    19.  
    20.  
    21. /*Lab1.c - Turn ON PORT B 0 LED*/
    22.  
    23. __CONFIG(0x3f31);
    24. unsigned long int i;
    25.  
    26. delay1s()
    27. {
    28.     for(i=0;i<30000;i++)
    29.     {
    30.         NOP();                //no operation is carried out
    31.     }
    32. }
    33.  
    34. main()
    35. {
    36.        TRISA = 0;
    37.     TRISB = 0b00001000;
    38.     TRISC = TRISD = 0;
    39.     PORTA = PORTB = PORTC = PORTD = 0;
    40.  
    41.     //ADC OFF
    42.     ADCON0 = 0;
    43.     ADCON1 = 0b110;
    44.    
    45.     //control bytes for usart( Bluetooth )
    46.     SPBRG = 25; //4MHz
    47.     TXSTA = 0x24;
    48.     RCSTA = 0x90;
    49.  
    50.     //USART interrupt
    51.     RCIE = 1;
    52.     GIE  = 1;
    53.     PEIE = 1;
    54.  
    55.  
    56.    
    57.  
    58.  
    59.     while(1)
    60.     {
    61.         PORTB=0x01; //set pin0 of portb as high
    62.       delay1s();
    63.  
    64. lcd_goto(1,1);
    65.  
    66.     PORTB=0x00; //set pin0 of portb as high
    67.  
    68. TXREG = 'A';
    69.  
    70.                
    71.         }
    72. }
    73.  
    74. void interrupt usart(void) {
    75.  
    76.     if ( RCIE && RCIF )
    77.     {
    78.         switch( RCREG  )
    79.         {
    80.             case 'A' :
    81.                 lcd_puts("hello");
    82.                 break;
    83.         }
    84.     }
    85.  
    86. }
    87.  
    88.  
    89. [/B]


    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: Jan 30, 2014
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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 ;)
     
  3. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    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!!
     
  4. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
    I don't see any error message. I never used Hi-tech, and now I'm glad that I haven't.
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012

    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.
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    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: Jan 30, 2014
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    I'm guessing the assignment is already past due and we won't hear back.
     
    JohnInTX likes this.
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    LOL! - I'm off to make dinner..
     
Loading...