Questions?


Closed Thread
Results 1 to 6 of 6

Thread: Questions?

  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Arrow Questions?

    Hello boys and girls,
    I have some questions using 16f628a 16Mhz

    1) HSERIN 500,MAIN,[WAIT(A), STR SERDATA\17]
    I input the A(byte) variable dit per bit and after that I want to read a stream which begins with A.Where is the wrong?Writting WAIT (A) it expects the ascii A which is something stable.

    2) WHILE PORTA.3 = 1 AND PORTA.4 = 1
    PAUSE 2000
    If PORTA.2=1 then
    I = I + 1
    IF I > 8 THEN I = 1
    pause 500
    NICK1: WHILE PORTA.3 = 1
    SerData[i] = "1"
    GOSUB OUT
    PAUSE 500
    WEND
    WHILE PORTA.4 = 1
    SerData[i] = "0"
    GOSUB OUT
    PAUSE 500
    WEND
    else
    GOTO NICK1
    endif
    WEND

    I have 3 buttons.WHILE PORTA.3 and PORTA.4 are pressed together the user can make some changes.If you press THE BUTTON of PORTA.2 you can move to the one of the 8 dot leds(i=1 to 8) and pressing button PORTA.3 or PORTA.4 you can display 1 or 0.
    My progaram is not working propertly but it is works.How can I do much more easier and smaller?


    Thanks
    Best regards
    Nikos Geronikolos
    HELLAS

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


    Did you find this post helpful? Yes | No

    Default

    Writting WAIT (A) it expects the ascii A which is something stable.
    WAIT("A")
    My progaram is not working propertly but it is works.How can I do much more easier and smaller?
    CMCON=7 ' disable analog comparator

    use Select Case will do the job.
    MyButtons=PORTA

    SELECT CASE Mybutton
    Case

    etc
    Steve

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

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You may find that SELECT CASE produces wonderfully readable listings for us programmers, the final compiled code it produces isn't particularly compact.

    Heaps of IF statements, although not particularly neat in listings, does however produce the most compact compiled code.

    Experiment one way, then the other and make your own mind up.

  4. #4
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Thanks mister_e & Melanie,

    I use SELECT CASE comands and it works much better.
    What about my first question?

    HSERIN 500,MAIN,[WAIT(A), STR SERDATA\17]
    The A is a byte.It is the start byte,an address of the stream that follows.I can change the A(byte) variable dit per bit.
    What I want is while I have set the A after I want to read a stream which begins with A.
    but this is not working.
    HSERIN 500,MAIN,[WAIT(A), STR SERDATA\17]

    If I change to WAIT("A") the pic search to read the A ASCII not the A that I have set manual.

    Please help me
    Thanks
    NIKOS
    HELLAS

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


    Did you find this post helpful? Yes | No

    Default

    If I change to WAIT("A") the pic search to read the A ASCII not the A that I have set manual.
    yup but for 500mSec. What about to try only that part without any timeout??? What about to add an optional end character???

    BTW, here's something to play with.
    Code:
        DEFINE LOADER_USED 1  ' Using Bootloader
        DEFINE OSC 20         ' Using 20MHZ crystal
        
        DEFINE HSER_RCSTA 90h ' Enable USART, continuous receive
        DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH=1
        DEFINE HSER_SPBRG 129 ' 9600 Bauds
        define HSER_CLOERR 1  ' Enable automatic alear overrun error
         
        StartByteChar   VAR	byte
        StringOfChar    VAR	Byte[10]
        Counter         var byte
        RecycleBin      var byte
        CLEAR ' set all variables to 0
    
    AskUser:
        hserout["Enter start byte character",13,10] ' 
        HSERIN [StartByteChar]                      ' wait user choice
            
    Start:
        Hserout["Waiting for start=",startbytechar,_
                " And 10 character string..........",13,10]           
                
        hserin[WAIT(Startbytechar),STR stringofchar\10] ' wait Start character
                                                        ' and store 10 next
                                                        ' character in StringOfChar
    
        for counter=0 to 9                 '
            hserout[stringofchar[counter]] ' Display results             
            next                           '
    
        While PIR1.5           ' Check RCIF => input buffer full??
              recyclebin=RCREG ' flush all results in a don't care variable
              wend             '
        
        RCSTA=0   ' simple way to clear all
        RCSTA=$90 ' possible errors
        pause 100 ' USART initialisation delay... value come from nowhere
        hserout[13,10,rep "*"\50,13,10] ' just to make it cute on screen
        goto askuser
    hope this help
    Steve

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

  6. #6
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    My friend mister_e,

    The start byte the user set it by pressing push buttons and you can see it to leds.
    So,

    A.0=LED1 ;0 OR 1
    A.1=LED2
    A.2=LED3
    A.3=LED4
    A.4=LED5
    A.5=LED6
    A.6=LED7
    A.7=LED8

    hserout[13,10,DEC A,13,10]

    ---------------------------------------------------

    By changing the A bit per bit I can see in my terminal the corect decimal A.

    HSERIN 500,MAIN,[WAIT(A), STR SERDATA\17]
    When I try to send with my terminal the start bit A & the stream the pic does not recognize nothing.

    IF I have set A = 01010101 MANUAL the pic expect to read the start bit A = 55 HEX?

Similar Threads

  1. Two quick (and elementary) questions.
    By scorpion990 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th June 2008, 23:03
  2. A few 12F683 questions
    By dhouston in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th May 2008, 03:54
  3. Usart Questions
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2008, 01:17
  4. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27
  5. Hi Everyone! Some newbie questions :-)
    By guest_05 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th October 2006, 22:24

Members who have read this thread : 1

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