RS232 & PIC18F


Closed Thread
Results 1 to 3 of 3

Thread: RS232 & PIC18F

  1. #1
    Christos_K's Avatar
    Christos_K Guest

    Default RS232 & PIC18F

    Sorry for all those continuous questions but its really frustrating! I used a PIC16f to communicate via rs232 to my pc! Everything worked ok!

    I now replaced the pic with a PIC18f2680 and I get nothing on the screen of my PC when sending a "Hello". Something is received but I think it is a problem with the communication protocols. Does anyone know how I need to set the HSER_BAUDCON register for 2400pbs communication?

    I though I could only set the brg16 to zero but nothing... Here is my code which worked (without the define hser_baudcon) with a pic16f.

    DEFINE HSER_RCSTA 90h 'Enable Serial PORT
    '8 bit reception
    'Disable Single receive
    'Enable continuous receive
    'All bytes received, diable address detection
    'No framming Error
    'No overrun error

    DEFINE HSER_TXSTA 20h '8 bit transmission
    'Enable transmit
    'Asyncronous mode
    'Low baud rate (BRGH=0)
    'TSR full

    define HSER_BAUDCON 0h
    DEFINE HSER_SPBRG 64 'set USART to 2400 baud (when BRGH=0)
    define hser_cloeer 1


    'Oscillation Settings
    '---------------------

    DEFINE OSC 10


    loop:

    hserout ["Hello",13]
    pause 100
    goto loop


    =====================
    Same code doesn't work with 18f2680.

    According to PIC18f2680 datasheet when Sync=0, BRGH=0 and BRG16=0 for 2400bps you set SPBRG = 64 at 10MHz...Could it be that some of the BAUDCON bits other than BRG16 shouldn't be 0??

  2. #2
    Christos_K's Avatar
    Christos_K Guest


    Did you find this post helpful? Yes | No

    Default

    Well something weired is happening now..Apparently I should have set the oscillator configuration bit to HS..(can anyone explain to me what are the differences of say xt, hs, lp tec?)..When i connect it starts showing dummy characters but when i press the reset button it sends the hello word as it should be...If i disconnect and connect again the same thing happens...I need to press reset ...Can anyone figure out or suggest why this is happening?

  3. #3
    angelika's Avatar
    angelika Guest


    Did you find this post helpful? Yes | No

    Default

    I think:

    TXSTA=%00100100 ' Enable transmit and asynchronous mode , 24h and not 20h
    DECLARE HSERIAL_CLEAR=ON ' Optionally clear the buffer before receiving
    Clear the overflow error bit before commencing a read.

    if I will find other wrong then I post it.(sorry for my bad english).

Similar Threads

  1. pic18f driving usb printers
    By ephesus in forum USB
    Replies: 18
    Last Post: - 22nd March 2012, 02:07
  2. Universal remote and Rs232
    By Michael in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th February 2010, 17:55
  3. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 18:27
  4. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 13:33
  5. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts