Serial Communication with PC code


Closed Thread
Results 1 to 5 of 5
  1. #1
    mike12345's Avatar
    mike12345 Guest

    Default Serial Communication with PC code

    Please forgive me, I am only a beginner...

    I want my PIC to send the constant 'name' over the serial port to my computer when a button is pressed. This is my first time with PICBasic so I may be completely wrong but what I want to do is put the PIC to sleep until and interrupt occurs. When there is an interrupt on RB0, the PIC will wake up and send data along the serial port. Any coding help is greatly appreciated. The code is below...

    -----------------------------------------------

    program wdev1

    const name = 0001

    PORTB.0 = 1 'port RBO as input?

    sub procedure interrupt 'interrupt procedure (I think)
    if INTCON.INTF = 1 then 'check port RBO

    USART_Write(name) 'send serial data (name)

    Delay_ms(1000) 'delay 1 second

    USART_Write(name) 'send second packet

    INTCON.INTF = 0 'set RBO to 0

    end if

    end sub

    main:

    INTCON = %10010000 'allow interrupts?

    USART_Init(2400) 'set baud rate to 2400

    asm 'include assembler code

    SLEEP 'sleep until interrupt method is called to preserve power

    end asm

    end.

    -----------------------------------------------
    Thanks a million!!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    what PIC compiler do you use... i feel that it's not the MELABS PICBasic
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    mike12345's Avatar
    mike12345 Guest

    Default Xcsb Lite

    I use XCSB LITE from http://www.xcprod.com/titan/XCSB/... is that any good? This is my first program ever on a PIC. Thanks.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    i can't tell if it's good or not 'cause i don't use it. I only use Melabs PICBASIC Pro and Hi-Tech C compilers.

    BUT as i read from your link, they have their own forum. Link bellow
    http://www.xcsb.com/cgi-bin/yabb/YaBB.cgi

    Good luck!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    mike12345's Avatar
    mike12345 Guest

    Default

    Thank you for the link...I had not noticed that before.

Similar Threads

  1. Serial Communication with PIC16F877A
    By mcbeasleyjr in forum General
    Replies: 16
    Last Post: - 28th May 2009, 01:38
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Serial communication between two 16F877As
    By campmdabt in forum Serial
    Replies: 5
    Last Post: - 24th June 2007, 06:41
  4. 18f4520 serial communication
    By merlinknight in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th March 2007, 15:30
  5. Serial Communication (PC to PIC)
    By Simon Brodeur in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th January 2006, 18:55

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