squelch doesn't seem the way to go


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by eng.alamin View Post
    you know if you use hardware UART your code will be much better in this case
    i already advised you to use pic's hardware UART in my first replay

    anyway any thing hard for first time don't be frustrated

    i don't know which pic that you use , so i assumed that you use pic16f877a

    here is small code will guide to use HARDWARE UART with pic basic pro

    Code:
    'small code for my friend 
    'eng.alamin
    '------------------------
    
    buffer var byte [10]  ' your stream buffers  
     x  var byte  ' for counter
    SPBRG = 12 ' 4800 clock must be 4MHz (sorry my friend but it's not inverted )
    
    RCSTA = %10010000  ' Enable RX
    TXSTA = %00100000  '    //    TX
    
    main
    
    low porta.0   '  disable your sqaulch circuit ;)
    gosub  lunix 
    gosub  pc
    
    lunix:
    if pir1.5 = 1 then     ' this is the wicked :)
    
    high porta.0    'Enable sqaulch circuit
    
    buffer[0]  = RCREG
    
    endif
    return
    
    
    pc :
    
    if PIR1.4 = 0 then pc   ' wait for loading 
    
    TXREG = buffer[0]     ' send data to your pc
    
    low porta.0   '  disable your sqaulch circuit ;)
    return

    this program will allow you to receive only one byte and transmit it
    edit and modify it according to your circuit to you have to work in loading all in coming data in buffer[x] by increasing x and adding some code line
    also you can invert logic by using NPN transistor
    ididn't compile this program i just worte it here so you may find dumb mistakes

    ---------

    regards
    Last edited by eng.alamin; - 2nd November 2008 at 10:24.

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


    Did you find this post helpful? Yes | No

    Default

    Two other Kick-Start codes

    http://www.picbasic.co.uk/forum/show...1&postcount=11

    http://www.picbasic.co.uk/forum/show...42&postcount=2

    Having a on-board USART allow to deal with interrupts as well... really handy... sort of background process.

    Make friend with USART section of your PIC datasheet. Usually, there's a load of information. Have a look to the related registers... see what you can use in.

    Obviously, if you plan to use interrupts, Instant Interrupts or ASM are welcome... see... mandatory.
    Last edited by mister_e; - 2nd November 2008 at 11:06.
    Steve

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

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks again for all of the suggestions, I will go back to the datasheet and and read about uart, Thanks Eng.Alamin for the sample, well I am off to see what I can accomplish with this information.

    Thanks again to all.

    By the way I am using the 16F628A processor.

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


    Did you find this post helpful? Yes | No

    Default

    Nice, it also have the built-in voltage comparator, reducing the external hardware to a minimum.
    Steve

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

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Although now I will focus on Uart, I been playing around this evening with my experiment after all I spent a lot of time on this and without etching a new pcb this would be sent to the scrapbox. I wanted to mention to Aratti that his sugggestion :
    Flag=0
    loop1:
    Flag=Flag+1
    If flag=>100 then goto Jumpout
    SERIN2 serialpinin,16468,100,loop1,[wait(254),a,b,c,d,e,f,g,h,i,j,k,l]
    Jumpout:
    At first it would not work for me and after all the questions I have asked on this forum one piece of advice stuck, that was when Skimask pointed out that "start thinking of PICs not as a teenager that can be told what to do ('cause that's what I see), but as a 6 year old that has to be told EXACTLY WHAT to do, WHEN to do it, HOW to do it, and to know yourself WHY he/she is doing what he/she is doing and HOW he/she is going to accomplish it". then Then light bulb lit in my head,I began to think how I could use Aratti's suggestion.
    Here is what I did:

    while flag < 1
    SERIN2 serpin,16468,[wait(254),a,b,c,d,e,]
    flag = flag + 1
    wend

    Now with the squelch wide open and the data pin toggling, Guess what??? It worked!!!!!!!!!!! keep in mind variable a-d are byte size and are all the same data and e is my check sum, the total sum of a-d, then I compare a-d if they match I multiply e * 4 and if it matches I count by 1 up to ten. If they don't match I set my counting variable1 to 0. If they match I set my counting variable2 to 1. If they match TEN times IN A ROW then my data is assumed good so I go to my next loop and turn on/off my functions, I seemed to have had some mutipath here in my metal barn so I just adjusted my counting variables to allow for errors. That kept my output on or off long enough to take some more samples. Now it works fast and seems very reliable. I've been doing flips etc. to make it act up and so far it hasn't missed anything that I know of, the outputs is on or off depending on if I was pressing the switch. Anyhow, I am waiting for the bubble to pop, LOL. As ya'll can see I don't like to give up. now that this is working, for now that is, I am off to UART. I'll be back with many more questions on that, I'm sure.

    Thanks everyone.
    Last edited by tazntex; - 3rd November 2008 at 03:00.

Similar Threads

  1. RF Transmitter/Reciver
    By Fredrick in forum General
    Replies: 75
    Last Post: - 4th May 2008, 01:19
  2. SERIN Timeout
    By George in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 23rd March 2007, 15:06

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