Serial data problem


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I just tried some test code out

    Code:
    'The main loop
    loop:
        
        'Check for serial data
        if pir1.5=1 then 'Check if there is any serial data
            while pir1.5 'Loop through all the data
                indata=RCREG 'Get a byte
                select case indata
                    case 255 'Reset the buffer
                        recpos=0
                    case else
                        if recpos<17 then
                            inbuffer(recpos)=indata
                            recpos=recpos+1
                        else
                            high porta.1
                        endif
                end select
            wend
            if rcsta.1=1 then
                rcsta.4=0
                rcsta.4=1
            endif
        endif
    goto loop
    Now, that code *should* wait for a 255. When it gets it it resets recpos to 0. Each byte after that should end up in InBuffer until recpos=17. At that point a light should turn on (porta.1)

    The reset part does seem to be working but not all the bytes arrive. The light wont come on until i send another 1-3 bytes.

    I should point out im not using the MAX232 chip because they havnt arrived yet but instead i linked into one of Matts boxes which has an alternative solution. I cant see why that would cause a problem but ive just found out that when i set the address it gets set to 1 less than what i actually set it to

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Woo. Its all working Ive only got 1 output working at the moment though. Ive got to put a loop in to handle all outputs and ive got to put the set address code back in but as it is the attached code is working perfectly.

    I only have 1 small problem with it. If i send data too fast then the light flickers slightly. Not enough to be annoying but i doubt the PC would ever send commands that fast anyway
    Attached Files Attached Files

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

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