Hot!pic16 to pc serial communication

Page: 123 > Showing page 1 of 3
Author
kishor009
Junior Member
  • Total Posts : 96
  • Reward points : 0
  • Joined: 2017/08/22 05:48:27
  • Location: india
  • Status: offline
2017/09/14 02:20:57 (permalink)
0

pic16 to pc serial communication

hiii
i try to communication between pic16 to pc 
my hardware is
 
pic16f1936  -> max485 ic  -> wire -> max485 ic -> max 232 ic -> pc
 
i send the data from pic16 to pc but nothing is receive
i use hyperterminal simulator 
 
my controller code is below
 
''
#include <pic16f1936.h>
void baud_rate_set();
void serial_init();
void uart_tx_config();


void baud_rate_set()
{
     BAUDCONbits.BRG16 = 0; // 8-bit Baud Rate Generator is used
     TXSTAbits.BRGH = 1; // high baud rate select
     SPBRG = 0x77; // for 9600 baud rate
}
void uart_tx_config()
{
     LATCbits.LATC5 = 1; // enable driver output
     RCSTAbits.CREN = 0; // disables continuous reception
     TXSTAbits.TXEN = 1; // Transmit enabled
}
void serial_init()
{
     TRISCbits.TRISC5 = 0; // set RC5 as a output
     TXSTAbits.SYNC = 0; // asynchronous mode
     RCSTAbits.SREN = 0; // disables single reception
     RCSTAbits.SPEN = 1; // Serial port enabled (configures TX/CK pins as serial port pins)
     PIE1bits.RCIE = 1; // disables the USART receive interrupt
     TRISCbits.TRISC6 = 0; // set RC6 as a output
}
void main()
{
    OSCCONbits.SCS0 = 0; // select external clock
    OSCCONbits.SCS1 = 0; // select external clock
    serial_init();
    baud_rate_set();
    uart_tx_config();
    while (1)
    {
         while (PIR1bits.TXIF == 0); // check TSR register is empty
         TXREG = 0x55; // send 'U'
     }
}
''
 
RE/DE pin of max485 is connect to RC5 pin 
post edited by kishor009 - 2017/09/16 07:28:53
#1

44 Replies Related Threads

    CinziaG
    morite
    • Total Posts : 3140
    • Reward points : 0
    • Joined: 2016/12/07 14:20:36
    • Location: Wien
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:30:49 (permalink)
    +2 (2)
    Write to LATx, not PORTx
     
    comes from
    http://www.microchip.com/forums/m1013839.aspx

    get my books!
    lulu.com search.ep?keyWords=greggio&type=
     
    #2
    katela
    Super Member
    • Total Posts : 547
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:36:53 (permalink)
    0
    CinziaG
    Write to LATx, not PORTx
     
    comes from
    http://www.microchip.com/forums/m1013839.aspx


    I don't think PIC16F have LAT registers 

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    Youtube Tutorials: http://www.youtube.com/user/StudentCompanionSA/videos
    #3
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:37:47 (permalink)
    +1 (1)

    I have tried both of these cases  LAT and PORT
    #4
    katela
    Super Member
    • Total Posts : 547
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:41:57 (permalink)
    +1 (1)
    kishor009

    I have tried both of these cases  LAT and PORT


    And if you connect your board to max 232 ic ---> to PC directly  without the RS485 link, does it work? It always good to isolate the problem stage by stage.

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    Youtube Tutorials: http://www.youtube.com/user/StudentCompanionSA/videos
    #5
    CinziaG
    morite
    • Total Posts : 3140
    • Reward points : 0
    • Joined: 2016/12/07 14:20:36
    • Location: Wien
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:44:02 (permalink)
    +1 (1)
    katela
     
    I don't think PIC16F have LAT registers 




    the enhanced ones should Smile
    from 1st post: pic16f1936  -> max485 ic  -> wire -> max485 ic -> max 232 ic -> pc

    get my books!
    lulu.com search.ep?keyWords=greggio&type=
     
    #6
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:45:40 (permalink)
    0

    I will not check that
     

    But this is a good idea
    #7
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 02:54:20 (permalink)
    0

    But I have to communicate between two PIC16 using the 485 link

    And now I want to talk between PC and PIC16, so I have to use max232
     
    that means there is no problem in max485 link
     
    #8
    qhb
    Superb Member
    • Total Posts : 6257
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 04:23:35 (permalink)
    +3 (3)
    kishor009

    But I have to communicate between two PIC16 using the 485 link
    And now I want to talk between PC and PIC16, so I have to use max232
    that means there is no problem in max485 link

    That logic does not make sense.
    The secret to good fault finding is to fix one problem at a time.
    Get this going WITHOUT the RS485 link first.
     
     
    #9
    katela
    Super Member
    • Total Posts : 547
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 05:10:30 (permalink)
    +1 (1)
    CinziaG
     
    the enhanced ones should Smile
    from 1st post: pic16f1936  -> max485 ic  -> wire -> max485 ic -> max 232 ic -> pc


    Yes.grin: grin

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    Youtube Tutorials: http://www.youtube.com/user/StudentCompanionSA/videos
    #10
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 05:32:26 (permalink)
    +1 (1)

    I saw the direct connection of PIC and max232 but did not get any output
    my hardware connection is,
     
    for pic16 to max232
     
    pin17(tx) of pic16 is direct connect to pin11(T1IN) of max232
    pin18(rx) of pic16 is direct connect to pin12(R1OUT) of max232
     
    for max232 to DB9(pc)
     
    pin14(T1OUT) of max232 is direct connect to pin2(RXD) of DB9
    pin13(R1IN) of max232 is direct connect to pin3(TXD) of DB9
    pin5 of DB9 is ground
    #11
    katela
    Super Member
    • Total Posts : 547
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 06:04:20 (permalink)
    +1 (1)
    Now at least you have isolated one problem.
    Before checking the PC connection, you should test the USART output first.
    What do you mean by you don't get any output? Can you detect any COM port on your PC after plugging your board?  If yest, did you select this COM port in your hyper terminal? Are you connecting to the normal COM port or serial to USB?
    Can you post your max232 connections whether you used the recommended capacitors on pin 1,3,4,5 on Vs+, Vs-?

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    Youtube Tutorials: http://www.youtube.com/user/StudentCompanionSA/videos
    #12
    Alpha Whisky
    Senior Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2014/10/02 07:05:22
    • Location: 0
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 07:20:11 (permalink)
    0
    It has been a while since I used hyperterminal. Any one know if it even does anything when it receives an ASCII "SOH" character?
    #13
    CinziaG
    morite
    • Total Posts : 3140
    • Reward points : 0
    • Joined: 2016/12/07 14:20:36
    • Location: Wien
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 07:25:29 (permalink)

    get my books!
    lulu.com search.ep?keyWords=greggio&type=
     
    #14
    mbrowning
    Just a Member
    • Total Posts : 598
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 07:31:41 (permalink)
    +1 (1)
    Alpha WhiskyIt has been a while since I used hyperterminal. Any one know if it even does anything when it receives an ASCII "SOH" character?

    I don't believe Hyperterm prints non-printable characters. I saw this too but this and related threads have been so surreal that I had to retreat into the peace of macros

    Can't remember. I've slept since then - Mark
    #15
    Alpha Whisky
    Senior Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2014/10/02 07:05:22
    • Location: 0
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/14 07:47:51 (permalink)
    +2 (2)
    LoL: LoL
    Personally I generally tend to use PuTTY as a terminal for interacting in ASCII and RealTerm for debugging binary serial streams. Haven't seen Hyperterminal used in anger for ages. Probably because it last came supplied with Windows XP.
    #16
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/15 21:26:03 (permalink)
    0
    katela
     
    Can you post your max232 connections whether you used the recommended capacitors on pin 1,3,4,5 on Vs+, Vs-?




    yes
    #17
    qhb
    Superb Member
    • Total Posts : 6257
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/15 21:32:36 (permalink)
    +2 (2)
    Please actually show your schematic with the MAX232 chip.
    Just answering "yes" to a detailed question is lazy, and not very helpful.
     
    #18
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/15 22:40:54 (permalink)
    0
    my schematic, 
    but i do not placed 10uf capacitor in between pin16(max232) and ground
    #19
    qhb
    Superb Member
    • Total Posts : 6257
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: pic16 to pc serial communication 2017/09/15 22:45:56 (permalink)
    +1 (1)
    Do you have an oscilloscope, or a logic probe?
    i.e. something to check the signal as it travels from your PIC to your PC?
     
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2017 APG vNext Commercial Version 4.5