PIC 16F877A serial communication

Author
Jhonmaclearen
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2013/03/26 11:58:31
  • Location: 0
  • Status: offline
2013/03/26 12:16:23 (permalink)
0

PIC 16F877A serial communication

Hi
i have been working on a project where i am able to control 24 leds on a pic 16f877a each led turns on or off according to ascii chars which are sent from the computer. For example if i send A to the PIC led's on Port B Light up to make letter A and the same with all letters. Now i am trying to make a four letter word but i am unable to capture the characters sent from the computer and Light the whole 24 leds according to Word which was sent from the computer. So how can i take the chars sent from the computer and act accordingly. because i cannot separate each char one i put them in the array (I am using C Coding).
 
 
#1

7 Replies Related Threads

    WaltR
    Super Member
    • Total Posts : 3759
    • Reward points : 0
    • Joined: 2003/11/07 12:38:21
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/26 12:51:22 (permalink)
    0
    Use the PIC's UART.
    Read the USART section of the PIC's data sheet. Read the Microchip App Note on serial communications using the UART, AN510, AN555 & AN774.
     
    Search the forums here as this is a very common question and there are lots of answers.
    Google "asynchronous serial", "UART" &  "RS232" to learn more of what is required.
     
    Also googling "PIC16F877 UART", "PIC16F877 serial comm" will find you lots of info on connecting to a PC comm port since this is a very popular PIC and is a very commonly required task.
    post edited by WaltR - 2013/03/26 12:56:59
    #2
    Jhonmaclearen
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2013/03/26 11:58:31
    • Location: 0
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/26 13:13:35 (permalink)
    0
    Thank you for the fast replay
    I am able to send and receive from the computer to pic, and i am familiar with UART communication what i can't do is make the pic recognize multiple characters sent from the computer at the same time. i can deal with one character but i can't  break the 4 character word sent from the computer to use IF conditions for each character.
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 14948
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/26 14:24:12 (permalink)
    0
    It is unclear what you want.  You pull the chars from the UART one at a time.  You can tell if you have one or four. If you a sending variable length messages, then you need and End of message character, or an itermessage time gap.
    #4
    Jhonmaclearen
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2013/03/26 11:58:31
    • Location: 0
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/27 05:17:30 (permalink)
    0
    I send space at the end to stop the sending , but i cant control the leds using the array of charecters that i have collected because i cannot take each charecter alone with it's position from the array once it's in it (in ascii) (C language).
    #5
    Ian.M
    Super Member
    • Total Posts : 13069
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/27 05:24:24 (permalink)
    +2 (1)
    It sounds like you have some conceptual problems with C arrays and your program structure.  If you show us your code we can help you understand where you are going wrong.
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 14948
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/27 08:29:43 (permalink)
    0
    You mean:
    theChar = array[index];
     
    Array and a function?
    for (X=0;X<3;X++)
    {
    write(array[X], X)];
    }
     
    I second the Post Some Code
    #7
    Jhonmaclearen
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2013/03/26 11:58:31
    • Location: 0
    • Status: offline
    Re:PIC 16F877A serial communication 2013/03/28 16:11:26 (permalink)
    0
    Yes NKurzman that's what i was looking for, thank you very much, now i am having trouble turning the leds on and off according to the letters in the array, each letter should have it's own port. For example if i send Jhon the first letter J in the array should turn on Leds in port A to make the letter J shape, and then the second letter h on Port B and the same for all letters.
     
    #8
    Jump to:
    © 2017 APG vNext Commercial Version 4.5