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 remarking out - didnt work
    ADCON1.7 = 0 - didnt work
    ADCON1.7 = 1 - WORKED!

    OK so now we are sending to the computer what we need. Now to get the part to receive from the PC a Byte.

    Heres my modified code, its been reworked several times stuff moved round Ill make notes at bottom of what its doing.

    Code:
    Include "12F1572.bas"
    DEFINE OSC 20
    
    DEFINE ADC_BITS 10 ' A/D number of bits
    DEFINE ADC_CLOCK 1 ' 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
    
    ADCON1.7 = 1
    TRISA = %00000100
    ANSELA = %00000100      
    
    A VAR word 'Stores 10 Bit Analog Reading
    B var byte
    
    mainloop: 
    b = 0
    porta.4 = 1
    pause 250 
    porta.4 = 0
    HSERIN 250, test,[B] : Pause 50 
    goto mainloop		' Do it all over again
    
    test:
    ADCIN 2, A   'Grab analog input from pin3
    pause 250
    Hserout [#A,13,10]		' Send char out serial port
    porta.4 = 1
    pause 1000
    porta.4 = 0
    goto mainloop
    ok, it goes in blinks the led quick and starts the line of code for hserin then it jumps to the test loop runs the adc and sends to the pc and the led continues to blink at 1 sec intervals, it never does the quick led blink of the main loop when test loop led duration is longer. and im not sure if I have the HSERIN coded right, it was taken from other code I had working last year with another chip. the weird thing is, if I change the mainloop led to 1000 and the test loop to 250, it still blinks at the 1 sec rate????
    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
    Nov 2003
    Location
    Greece
    Posts
    4,132

    Default Re: HELP! HSER issues from old to new

    If it does not do the fast blink, that may imply that there is data on the Serial port. Even one character is enough to exit from the HSERIN loop.

    Maybe it is better to have a different LED port for the mainloop and another for the test loop.

    Ioannis

Similar Threads

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