HELP! HSER issues from old to new


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default Re: HELP! HSER issues from old to new

    Ok I found a way around to get my code to show up right, I could really use some help getting this to work.
    I have a project that needs this interface and I want to get it running by the 28th before I get back home.

    Code:
    define OSC 4
    
    DEFINE ADC_BITS 16 ' A/D number of bits
    DEFINE ADC_CLOCK 3 ' Uses A/D internal RC clock
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
    
    define HSER_BAUD 9600
    DEFINE HSER_BITS 8
    DEFINE HSER_CLROERR 1
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_SPBRG 25
    DEFINE HSER_SPBRGH 0
    
    A VAR WORD 'Stores 16 Bit Analog Reading
    B VAR byte 'Temp Holder
    Switch VAR PORTA.5 'Controls External FET or LED on pin 2
    Switch = 0
    
    mainloop: 
    ADCIN 2, A   'Grab analog input from Pin 3
    
    Hserout [A]		' Send char out serial port
    pause 100
    
    HSERIN [B]
    if B = 5 then switch = 1 else switch = 0	
    pause 100
    
    goto mainloop		' Do it all over again
    Attached Files Attached Files
    Last edited by wdmagic; - 23rd October 2015 at 02:10.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default Re: HELP! HSER issues from old to new

    Hi WD,
    I am not sure which part you are having trouble with, and am presently unable to work on HSER*** but I played with your code using a 16F690 demo board and debug and pretty well got it to function, accuracy notwithstanding . . .
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    ; DEFINE LOADER_USER 1   ' Boot-Loader is being used
    DEFINE OSC 4          ' Change to your chip
    DEFINE DEBUG_MODE  0         ' Debug sending True serial data
    DEFINE DEBUG_REG_PORTA       ' Debug Port = PortA as required by PICKIT2 serial Monitor
    DEFINE DEBUG_BIT 0           ' Debug.bit = PortA.0
    DEFINE DEBUG_BAUD 9600       ' Default baud rate = 9600
    DEFINE DEBUGIN_REG PORTA     ' Debug Port = PortA as required by PICKIT2 serial Monitor 
    DEFINE DEBUGIN_BIT 1         ' Debugin bit PortA.1
    DEFINE DEBUGIN_BAUD 9600     ' Default baud rate = 9600
    DEFINE DEBUGIN_MODE 0        ' Debugin receiving data true = 0 inverted = 1
    
    ;DEFINE HSER_BAUD	9600	' override the default of 2400
    ANSEL  = 0                   ' 
    ANSELH = 0       
    ADCON0 = %00001011
    led	VAR portc.1		' change if needed				
    
    TrisC = %00000000
    TrisA = %00000010
    A VAR word 'Stores 16 Bit Analog Reading
    B0 VAR byte 'Temp Holder
    a=0
    b0=0
    Switch VAR byte
    ;portC = %00000000
    mainloop: 
    ADCIN 2, A   'Grab analog input from RA2
    
    ;
    pause 100
    
    Debugin [B0]
        IF B0 = "5" THEN
             led = 1
             Debug " high fives"
             
        else
            led = 0
            Debug " still low"
            
     
    	
    pause 100
    Debug B0		' Send char out serial port
    endif
    A = a + 48
    debug A
    
    goto mainloop		' Do it all over again
    Maybe something useful in there.
    JS
    Last edited by Archangel; - 23rd October 2015 at 04:44.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Need help with HSER on the 16F747
    By allanb in forum Serial
    Replies: 2
    Last Post: - 18th September 2013, 05:28
  2. HSER baudrate
    By pedja089 in forum Serial
    Replies: 14
    Last Post: - 7th August 2011, 20:46
  3. HSER Problems
    By Kaldurenik in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 15th October 2007, 09:33
  4. HSER with interrupts
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th February 2007, 21:19
  5. Hser-rx test
    By nicjo in forum Serial
    Replies: 0
    Last Post: - 26th November 2006, 10:53

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