Wireless problem


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Now that I solved(or going to solve...) reliability problems, I find that serin/serout work fine while hserin/hserout seem to have more problem...

    Usart has been configured used pic multicalc.

    I noticed that Mister_E adds the comment "Enable serial port & continuous receive" setting rcsta receiver.
    Does it mean that hserin does not have to be in a loop? maybe something like:
    Code:
    hserin [#txpin]
    
    main:
      lcdout $fe,row1,dec txpin
    goto main
    could work?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    If you use the example you post, then you will display only the first byte and continue to display that exact byte endlessly.

    If you send serial data then the buffer of the 2-byte long USART will overflow and depending on the setup will stop with error flag raised or replace old bytes with the new ones.

    Please refer to your Data sheet of the PIC you are using for more infos about the USART and its associated flags and control bits.

    If serin/serout work then I am sure that USART will work better and without having PIC to deal with the data untill they are available to process. You must have something wrong with your setup.

    As Steve stated without the whole picture we can only guess.

    Here in Greece we had the ancient times the oracle at Delphi and Pythia making guesses and prophecies but nowadays I suppose it is better to see, measure calculate and then conclude. So if you want real help post all you got (schematics, cablings, software, defines etc).

    Ioannis

  3. #3
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    If you use the example you post, then you will display only the first byte and continue to display that exact byte endlessly.
    As the define comment says "continous receive" I guessed it could've be continuos receive in background while pic runs the program, as hpwm.

    Quote Originally Posted by Ioannis View Post
    If you send serial data then the buffer of the 2-byte long USART will overflow and depending on the setup will stop with error flag raised or replace old bytes with the new ones.
    I included DEFINE CLROERR 1 to clear overflow automatically.
    And surely I still have to study a lot....

  4. #4
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Finally!

    At last I've been able to use USART!
    On the tx side I changed serout from N2400 to T2400 and the rx started to display correct data! Data is sent 10ms after powering the txer.

    99% of data is correctly showed on the display.

    Now I have to mount the sensor and send acquired data along with a sort of checksum.

    I could stay hours watching the display:0...1...2...3...4..... to see if some of my numbers gets lost. Watching it for a minute, no problems!
    So here is the working code for the TX:
    Code:
    INCLUDE "modedefs.bas"
    
    ANSEL=0
    CMCON0=%00000111
    
    define osc 4
    txpin   var gpio.4
    led     var gpio.5
    power   var gpio.2
    i       var byte
    
    low power
    
    loop:
        for i=0 to 9
          high power
          pause 10
          serout txpin,t2400,[$55,$55,$55,$55,$66,#i]
          low power
          high led
          pause 30
          low led
          pause 1000
        next i
    goto loop
    And, of course RX:
    Code:
    define  OSC 20
    Define 	LCD_LINES	4			' Settings for a 4x20 LCD
    Define	LCD_DREG	PORTB		'   4bit mode
    Define	LCD_DBIT	4			'
    Define	LCD_RSREG	PORTB		
    Define	LCD_RSBIT	3		 	
    Define	LCD_EREG	PORTB'      
    Define	LCD_EBIT	2
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFine HSER_BAUD 2400
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    'LCD Lines constants
    row4        con	$d4
    row3	    con	$94
    row2	    con	$c0
    row1	    con $80
    hser var byte
    
    intcon=0
    
    pause 500
    lcdout $fe,1
    lcdout $fe, row1, "** RX TEST **"
    
    loop:
          hserin [wait($66),hser]
          hserout [#hser]
          lcdout $fe, row3," hser: ",dec1 hser
    goto loop
    Last edited by supersonic; - 19th December 2007 at 12:29.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Congratulations!

    Ioannis

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem with ASM IRQ using FSR0 on PIC18F252
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th March 2008, 20:48
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. CM02 and RF04 wireless modules problem
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th December 2006, 10:32
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

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