Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error: can't open include file "16F877a.h"

Status
Not open for further replies.

WhyWhy

Member level 4
Member level 4
Joined
Mar 18, 2013
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,779
Error in execution.

How to solve this problem? i using MPLAB, Project -> PIC16F877A -> Hi TECH ANSI -> Finish.
When i execute the error is occur.
Error:
Code:
Warning [162] C:\Program Files (x86)\HI-TECH Software\PICC\9.83\include\pic16f877a.h; 3.82 #warning: Header file pic16f877a.h included directly. Use #include <htc.h> instead.
Warning [107] C:\Users\WhyWhy\Desktop\test.c; 3.6 illegal # directive "fuses"
Warning [107] C:\Users\WhyWhy\Desktop\test.c; 4.4 illegal # directive "use"
Warning [107] C:\Users\WhyWhy\Desktop\test.c; 5.4 illegal # directive "use"
Warning [107] C:\Users\WhyWhy\Desktop\test.c; 9.8 illegal # directive "int_rda"
Warning [361] C:\Users\WhyWhy\Desktop\test.c; 12.4 function declared implicit int
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 14.9 char const too long
Warning [361] C:\Users\WhyWhy\Desktop\test.c; 15.1 function declared implicit int
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 15.13 undefined identifier "PIN_B0"
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 17.14 char const too long
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 18.13 undefined identifier "PIN_B1"
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 20.14 char const too long
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 21.13 undefined identifier "PIN_B2"
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 23.14 char const too long
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 24.13 undefined identifier "PIN_B3"
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 26.14 char const too long
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 27.13 undefined identifier "PIN_B4"
Error   [226] C:\Users\WhyWhy\Desktop\test.c; 29.14 char const too long
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 30.13 undefined identifier "PIN_B5"
Warning [361] C:\Users\WhyWhy\Desktop\test.c; 34.1 function declared implicit int
Warning [361] C:\Users\WhyWhy\Desktop\test.c; 46.1 function declared implicit int
Warning [361] C:\Users\WhyWhy\Desktop\test.c; 48.1 function declared implicit int
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 48.19 undefined identifier "int_rda"
Error   [192] C:\Users\WhyWhy\Desktop\test.c; 49.19 undefined identifier "global"

Code:
#include <pic16f877a.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

char rx;

#int_rda
void serial_isr()
{
rx=getch();

if (rx=='AA')
output_high(PIN_B0);

else if (rx=='BB')
output_high(PIN_B1);

else if (rx=='CC')
output_high(PIN_B2);

else if (rx=='DD')
output_high(PIN_B3);

else if (rx=='EE')
output_high(PIN_B4);

else if (rx=='FF')
output_high(PIN_B5);


else
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4);
output_low(PIN_B5);
}


void main()
{

set_tris_c(0b10000000); // I do not know how you drive the LED on C0: output/input?

enable_interrupts(int_rda);
enable_interrupts(global);

while(1);

}
 
Last edited:

Re: Error in execution.

Im not much aware on software front, but may be this can help u. I think, may be its compiler dependent. I use XC8 compiler with MPLAB X IDE. The other compiler that are compatible with this IDE are Hi Tech and C18.
Try using XC8 compiler in MPLAB X, may be it can solve the issue.

Hope that helps.
 

Re: Error in execution.

In Hi-Tech C you don't have to include header files for pic. You should instead include htc.h file like

Code C - [expand]
1
2
3
4
#include <htc.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

 

jayanth.devarayanadurga : Already change,still cant solve my problem :-(

ashugtiwari : Yeah,i downloading the XC 8 compiler and MPLAB X IDE. Did that mean i maybe can compile my code in MPLAB X IDE?
 

Have you selected the right tool i.e., picc.exe as compiler for the project.

Ok. I found the problem. Your code is actually CCS C code and not Hi Tech C code. Use CCS C compiler to compile the code and don't use htc.h header. Use the code you posted in the first post but in toolset you have to select ccs as the compiler for the project if you are using mplab or mplabx ide.

Your code will still not compile as there is many errors.

Code C - [expand]
1
2
3
rx=getch();
 
if (rx=='AA')



getch() returns a single character like 'A' and in the if statement you are checking if rx == 'AA' i.e., two characters, so none of your if...eleeif conditions will execute. Please see CCS C Code examples in CCS C installation folder. You need to have CCS C Compiler to compile your code but you can use CCS C IDE or MPLAB or MPLABX IDE.

'AA' is illegal. single quotes are used to enclose single characters. For string you have to use double quotes like "AA".
 
Last edited:

yes, u can. just select xc8 compiler in MPLAB X and u r done and can include pic16f877a.h directly. Also, as jayanth said, u can just try changing the compiler in ur current mplab. may be that solves the problem.
Hope that helps.
 

Thanks for the replies from both of you
jayanth : since the getchar() just can return single string,mean that illegal to do the code like below ?
Sorry because i still a beginneer :-(
Code:
if (rx=="AA")
output_high(PIN_B0);

else if (rx=="BB")
output_high(PIN_B1);

else if (rx=="CC")
output_high(PIN_B2);

else if (rx=="DD")
output_high(PIN_B3);

else if (rx=="EE")
output_high(PIN_B4);

else if (rx=="FF")
output_high(PIN_B5);
 

getchar() returns a single character. So, you get single character in rx variable. you have to use rx == 'A' and similar statements. Yes it is illegal.

rx = 'A' legal
rx = 'AA' illegal
rx = "A" illegal
rx = "AA" illegal

You are using PORTB for LEDs, So, you have to make PORTB as digital output port with set_tris_b(0b00000000); statement

You have to send 'A', 'B', 'C'... from PC to MCU UART. Is there MAX232 between PC and MCU?
 
Last edited:
  • Like
Reactions: WhyWhy

    WhyWhy

    Points: 2
    Helpful Answer Positive Rating
Actually i doing a project which Visual Basic Express 2010 will Turn On The LED follow by the text in a textbox (data retrieve from database).Example: "AA" = LED A ( ON )
So Far,I already testing the coding for VB 2010 can send AA out and receive AA back by connect the TX to RX pin using jumper.
Just now i already download the CSS C Compiler from **broken link removed** and i select the toolsuite as CSS C Compiler at MPLAB IDE then execute my program.
But when i execute the coding below,The error is occur (Error : Unable to open file 'FM' , Error options: -ew: no warning details -ed: no error details -eL: list details)
Code:
#include <pic16f877a.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

char rx;

#int_rda
void serial_isr()
{
rx=getch();

if (rx=="AA")
output_high(PIN_B0);

else if (rx=="BB")
output_high(PIN_B1);

else if (rx=="CC")
output_high(PIN_B2);

else if (rx=="DD")
output_high(PIN_B3);

else if (rx=="EE")
output_high(PIN_B4);

else if (rx=="FF")
output_high(PIN_B5);


else
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4);
output_low(PIN_B5);
}


void main()
{

set_tris_B(0b00000000); // I Make PIN B as Output

enable_interrupts(int_rda);
enable_interrupts(global);

while(1);

}
Yup,This is my Max232A.
3.png
 

Post the screenshot of error message. Can you modify your VB program to send 'A' instead of 'AA'? Post your VB Code.

Try this code.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <pic16f877a.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
 
unsigned char rx[3];
unsigned int i = 0;
 
#int_rda
void serial_isr()
{
    
    rx[i]=getch();
    i++;
 
    if(i == 2){ i = 0; rx[2] = '\0';}
 
    if (rx=="AA")
        output_high(PIN_B0);
 
    else if (rx=="BB")
        output_high(PIN_B1);
 
    else if (rx=="CC")
        output_high(PIN_B2);
 
    else if (rx=="DD")
        output_high(PIN_B3);
 
    else if (rx=="EE")
        output_high(PIN_B4);
 
    else if (rx=="FF")
        output_high(PIN_B5);
 
 
    else {
        output_low(PIN_B0);
        output_low(PIN_B1);
        output_low(PIN_B2);
        output_low(PIN_B3);
        output_low(PIN_B4);
        output_low(PIN_B5);
       }
}
 
 
void main()
{
 
    set_tris_B(0b00000000); // I Make PIN B as Output
 
    enable_interrupts(int_rda);
    enable_interrupts(global);
 
    while(1);
 
}



Instead of

Code C - [expand]
1
2
3
4
5
6
output_low(PIN_B0);
        output_low(PIN_B1);
        output_low(PIN_B2);
        output_low(PIN_B3);
        output_low(PIN_B4);
        output_low(PIN_B5);



see if there is any option to clear the whole port like output_low(PORT_B);
 
Last edited:

I use your coding the error still same . Could it possible error because of i using MPLAB IDE not MPLAB X ?
4.png
my visual basic code that can send "AA" to PIC and return back "AA" without using database.i not yet combine my both visual basic which connect to database because need settle this Serial Communication first.
Code:
Imports System
Imports System.IO.Ports
Imports System.Threading
Imports System.Threading.Thread
' Imports the System, System.IO.Ports and System.Threading.Thread namespaces so that e.g.
'   System.IO.Ports.SerialPort may just be written as SerialPort, and System.EventArgs may just be
'     written as EventArgs.

Public Class MaxiTester

    Dim SpaceCount As Byte = 0
    Dim LookUpTable As String = "0123456789ABCDEF"
    Dim RXArray(2047) As Char ' Text buffer. Must be global to be accessible from more threads.
    Dim RXCnt As Integer      ' Length of text buffer. Must be global too.

    ' Make a new System.IO.Ports.SerialPort instance, which is able to fire events.
    Dim WithEvents COMPort As New SerialPort

    Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles COMPort.DataReceived
        Dim RXByte As Byte
        Do
            '----- Start of communication protocol handling -----------------------------------------------------------
            ' The code between the two lines does the communication protocol. In this case, it simply emties the
            '   receive buffer and converts it to text, but for all practical applications, you must replace this part
            '     with a code, which can collect one entire telegram by searching for the telegram
            '       delimiter/termination. In case of a simple ASCII protocol, you may just use ReadLine and receive
            '         in a global string instead of a byte array.
            ' Because this routine runs on a thread pool thread, it does not block the UI, so if you have any data
            '   convertion, encryption, expansion, error detection, error correction etc. to do, do it here.
            RXCnt = 0
            Do
                RXByte = COMPort.ReadByte
                RXArray(RXCnt) = LookUpTable(RXByte >> 4) ' Convert each byte to two hexadecimal characters
                RXCnt = RXCnt + 1
                RXArray(RXCnt) = LookUpTable(RXByte And 15)
                RXCnt = RXCnt + 1
                RXArray(RXCnt) = " "
                RXCnt = RXCnt + 1
                SpaceCount = (SpaceCount + 1) And 31      ' Insert spaces and CRLF for better readability
                If SpaceCount = 0 Then                    ' Insert CRLF after 32 numbers
                    RXArray(RXCnt) = Chr(13) ' CR
                    RXCnt = RXCnt + 1
                    RXArray(RXCnt) = Chr(10) ' LF
                    RXCnt = RXCnt + 1
                Else
                    If (SpaceCount And 3) = 0 Then        ' Insert two extra spaces for each 4 numbers
                        RXArray(RXCnt) = " "
                        RXCnt = RXCnt + 1
                        RXArray(RXCnt) = " "
                        RXCnt = RXCnt + 1
                    End If
                End If
            Loop Until (COMPort.BytesToRead = 0)
            '----- End of communication protocol handling -------------------------------------------------------------
            Me.Invoke(New MethodInvoker(AddressOf Display)) ' Start "Display" on the UI thread
        Loop Until (COMPort.BytesToRead = 0)  ' Don't return if more bytes have become available in the meantime
    End Sub

    ' Text display routine, which appends the received string to any text in the Received TextBox.

    Private Sub Display()
        Received.AppendText(New String(RXArray, 0, RXCnt))
    End Sub

    ' Transmitter subroutine.

    Private Sub Transmitter(ByVal sender As Object, ByVal e As EventArgs) Handles SendButton.Click
        Received.AppendText("TX" & vbCrLf)        ' Switch to a new line after every transmission
        SpaceCount = 0
        Dim TextString As String
        Dim TXArray(2047) As Byte
        Dim I As Integer
        Dim J As Integer = 0
        Dim Ascii As Boolean = False
        Dim Quote As Boolean = False
        Dim Temp As Boolean
        Dim Second As Boolean = False
        Dim TXByte As Byte = 0
        Dim CharByte As Byte
        If COMPort.IsOpen Then
            TextString = Transmitted.Text
            For I = 0 To TextString.Length - 1
                CharByte = Asc(TextString.Chars(I))
                If CharByte = 34 Then ' If " Then
                    Temp = Ascii
                    Ascii = Ascii Or Quote
                    Quote = Not (Temp And Quote)
                Else
                    Ascii = Ascii Xor Quote
                    Quote = False
                End If
                If Not Quote Then
                    If Ascii Then
                        TXArray(J) = CharByte
                        J = J + 1
                    Else
                        If (CharByte <> 32) And (CharByte <> 10) And (CharByte <> 13) Then ' Skip spaces, LF and CR
                            CharByte = (CharByte - 48) And 31 ' And 31 makes it case insensitive
                            If CharByte > 16 Then
                                CharByte = CharByte - 7
                            End If
                            If Second Then
                                TXArray(J) = TXByte + CharByte
                                Second = False
                                J = J + 1
                            Else
                                TXByte = CharByte << 4
                                Second = True
                            End If
                        End If
                    End If
                End If
            Next
            Try
                COMPort.Write(TXArray, 0, J)
            Catch ex As Exception
                MsgBox(ex.Message & "  Check CTS signal or set Flow Control to None.")
            End Try
        Else
            MsgBox("COM port is closed. Please select a COM port")
        End If
    End Sub

    ' This subroutine handles a change of COM ports.

    Private Sub PortSelection(ByVal sender As Object, ByVal e As EventArgs) Handles COMPortsBox.SelectedIndexChanged
        RTSLamp.BackColor = Color.Gray
        DTRLamp.BackColor = Color.Gray
        If COMPort.IsOpen Then
            COMPort.RtsEnable = False
            COMPort.DtrEnable = False
            ClosePort()
            ' NOTE. Because of the use of Invoke, the port should normally be closed from a different thread, see
            '   MaxiTesterClosing, but to ensure that the following delay works, this is not done in this case.
            ' Empty the message queue before the UI thread goes to sleep to update the modem lamps and the ComboBox.
            Application.DoEvents()
            Sleep(200)                      ' Wait 0.2 second for port to close as this does not happen immediately.
        End If
        COMPort.PortName = COMPortsBox.Text
        COMPort.BaudRate = 19200            ' Default for Max-i: 19200 bit/s, 8 data bits, no parity, 1 stop bit
        COMPort.WriteTimeout = 2000         ' Max time to wait for CTS = 2 sec.
        ' COMPort.ReadBufferSize = 16384      Necessary buffer size for 16C950 UART at 921.6 kbit/s
        Try
            COMPort.Open()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        BaudRateBox.Text = COMPort.BaudRate.ToString
        BitsBox.Text = COMPort.DataBits.ToString
        ParityBox.Text = COMPort.Parity.ToString
        FlowControlBox.Text = COMPort.Handshake.ToString
        If COMPort.IsOpen Then
            COMPort.RtsEnable = True
            RTSLamp.BackColor = Color.LightGreen
            COMPort.DtrEnable = True
            DTRLamp.BackColor = Color.LightGreen
        End If
    End Sub

    ' This subroutine is activated when the form is loaded. It does all the basic initializations.
    ' Note! Baud Rates above 115.2 KBaud requires a special UART like e.g. 16C650, 16C750, 16C850 or 16C950 and
    '   a special driver.
    ' RTS/CTS hardware flow control is necessary for Max-i communication. Note that the standard UART 16C550
    '   has no hardware flow control - except for UART's from Texas Instruments.
    ' The minimum FIFO size is calculated on the basis of a 1.4 mS response time, which is the absolute minimum
    '   for Windows applications.

    Private Sub MaxiTesterLoad(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        For Each COMString As String In My.Computer.Ports.SerialPortNames ' Load all available COM ports.
            COMPortsBox.Items.Add(COMString)
        Next
        COMPortsBox.Sorted = True
        BaudRateBox.Items.Add("110")
        BaudRateBox.Items.Add("300")
        BaudRateBox.Items.Add("600")
        BaudRateBox.Items.Add("1200")
        BaudRateBox.Items.Add("1800")
        BaudRateBox.Items.Add("2400")
        BaudRateBox.Items.Add("4800")
        BaudRateBox.Items.Add("7200")
        BaudRateBox.Items.Add("9600")
        BaudRateBox.Items.Add("14400")
        BaudRateBox.Items.Add("19200")      ' Min. FIFO size 3 Bytes (8030 or 8530)
        BaudRateBox.Items.Add("38400")
        BaudRateBox.Items.Add("57600")      ' Min. FIFO size 8 bytes
        BaudRateBox.Items.Add("115200")     ' Min. FIFO size 16 bytes (16C550)
        BaudRateBox.Items.Add("230400")     ' Min. FIFO size 32 bytes (16C650)
        BaudRateBox.Items.Add("460800")     ' Min. FIFO size 64 bytes (16C750)
        BaudRateBox.Items.Add("921600")     ' Min. FIFO size 128 bytes (16C850 or 16C950)
        BitsBox.Items.Add("5")
        BitsBox.Items.Add("6")
        BitsBox.Items.Add("7")
        BitsBox.Items.Add("8")
        ParityBox.Items.Add("None")
        ParityBox.Items.Add("Odd")
        ParityBox.Items.Add("Even")
        ParityBox.Items.Add("Mark")         ' Leaves the parity bit set to 1
        ParityBox.Items.Add("Space")        ' Leaves the parity bit set to 0
        FlowControlBox.Items.Add("None")
        FlowControlBox.Items.Add("RequestToSend")
        FlowControlBox.Items.Add("RequestToSendXOnXOff")
        FlowControlBox.Items.Add("XOnXOff")
        RTSLamp.BackColor = Color.Gray
        DTRLamp.BackColor = Color.Gray
        CTSLamp.BackColor = Color.Gray
        DSRLamp.BackColor = Color.Gray
    End Sub


    ' This subroutine is used to close the COM port. Because the program uses Invoke instead of BeginInvoke, this
    '   routine is usually called on a separate (new) thread to prevent a close-down deadlock.

    Private Sub ClosePort()
        If COMPort.IsOpen Then COMPort.Close()
    End Sub

    ' This subroutine is activated when the form is closed. It closes the COM port. Without such a close command,
    '   the garbage collector may close the COM port while it is still in use!

    Private Sub MaxiTesterClosing(ByVal sender As Object, ByVal e As ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If MessageBox.Show("Do you really want to close the window", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
            e.Cancel = True
        Else
            ' Close COM port on a new thread when the form is terminated with [X]
            Dim t As New Thread(AddressOf ClosePort)
            t.Start()
        End If
    End Sub

    ' This subroutine clears the Received TextBox for received bytes.

    Private Sub ClearReceivedText(ByVal sender As Object, ByVal e As EventArgs) Handles ClearButton.Click
        Received.Text = ""
        SpaceCount = 0
    End Sub

    ' This subroutines inserts a Break condition.

    Private Sub SendBreak(ByVal sender As Object, ByVal e As EventArgs) Handles BreakButton.Click
        If COMPort.IsOpen Then
            COMPort.BreakState = True
            Sleep((11000 / COMPort.BaudRate) + 10)
            ' Min. 11 bit delay (startbit, 8 data bits, parity bit, stopbit). 10 mS have been added to ensure that
            '   the delay is always active. If the delay time is less than the task switching time, the two BreakState
            '     instructions may be activated immediately after each other ! On a multiprocessor system, you must
            '       add 15 mS instead.
            COMPort.BreakState = False
        Else
            MsgBox("No COM Port Selected")
        End If
    End Sub

    ' This subroutine handles a change in Baud Rate.

    Private Sub BaudRateSelection(ByVal sender As Object, ByVal e As EventArgs) Handles BaudRateBox.SelectedIndexChanged
        COMPort.BaudRate = CInt(BaudRateBox.Text)
    End Sub

    ' This subroutine handles a change in number of data bits

    Private Sub DataBitsSelection(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BitsBox.SelectedIndexChanged
        COMPort.DataBits = CInt(BitsBox.Text)
    End Sub

    ' This subroutine handles a change in the parity.

    Private Sub ParitySelection(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParityBox.SelectedIndexChanged
        COMPort.Parity = CType([Enum].Parse(GetType(Parity), ParityBox.Text), Parity)
    End Sub

    ' This subroutine handles a change in the flow control (handshake).

    Private Sub SoftwareFlowControlSelection(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FlowControlBox.SelectedIndexChanged
        COMPort.Handshake = CType([Enum].Parse(GetType(Handshake), FlowControlBox.Text), Handshake)
    End Sub

    ' This subroutine updates the modem control signal lamps

    Private Sub ModemLamps(ByVal sender As Object, ByVal e As SerialPinChangedEventArgs) Handles COMPort.PinChanged
        If COMPort.DsrHolding Then
            DSRLamp.BackColor = Color.LightGreen
        Else
            DSRLamp.BackColor = Color.Gray
        End If
        If COMPort.CtsHolding Then
            CTSLamp.BackColor = Color.LightGreen
        Else
            CTSLamp.BackColor = Color.Gray
        End If
    End Sub

    ' This subroutine saves the content of the Received TextBox

    Private Sub SaveText(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim SaveFileDialog1 As New SaveFileDialog()
        SaveFileDialog1.Filter = "Text Files (*.txt)|*.txt"
        SaveFileDialog1.Title = "Save Received As"
        If SaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK _
            And SaveFileDialog1.FileName.Length > 0 Then
            My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, Received.Text, False) ' Overwrite file
        End If
    End Sub

    Private Sub Received_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Received.TextChanged

    End Sub
End Class
 
Last edited:

See image. You are using wrong Compiler. You are using CC5X Compiler. You have tp use PCWHD CCS C Compiler. https://www.ccsinfo.com/

Try Compiling my last code with CCS C Compiler. Download and install demo version of CCS C and use it as toolsuite in MPLAB or Compile the project in CCS C Compiler IDE.
 

Re: Error: can't open include file &quot;16F877a.h&quot;

I went to https://www.ccsinfo.com/ to download the CcS C Compiler,before i download i need to submit the survey at https://www.ccsinfo.com/ccsfreedemo.php?action=submit
Problem is the cannot submit because of the security code. (26f7f)
Error Please enter the text in the blue picture

- - - Updated - - -

Yeah~ i build the code succeeded already.
i include the file 16F877.h because there is no pic16F877a.h or 16F877a in the directory.
The below coding can help me receive signal that transmit from visual basic to PIC ? I not really sure because i not have serial_isr() function at the void main there,is that ok ?
Code:
#include <16F887.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
 
unsigned char rx[3];
unsigned int i = 0;
 
#int_rda
void serial_isr()
{
    
    rx[i]=getch();
    i++;
 
    if(i == 2){ i = 0; rx[2] = '\0';}
 
    if (rx=="AA")
        output_high(PIN_B0);
 
    else if (rx=="BB")
        output_high(PIN_B1);
 
    else if (rx=="CC")
        output_high(PIN_B2);
 
    else if (rx=="DD")
        output_high(PIN_B3);
 
    else if (rx=="EE")
        output_high(PIN_B4);
 
    else if (rx=="FF")
        output_high(PIN_B5);
 
 
    else {
        output_low(PIN_B0);
        output_low(PIN_B1);
        output_low(PIN_B2);
        output_low(PIN_B3);
        output_low(PIN_B4);
        output_low(PIN_B5);
       }
}
 
 
void main()
{
 
    set_tris_B(0b00000000); // I Make PIN B as Output
 
    enable_interrupts(int_rda);
    enable_interrupts(global);
 
    while(1);
 
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top