Pic16f84 and wait byte


Closed Thread
Results 1 to 21 of 21
  1. #1
    irmus's Avatar
    irmus Guest

    Default Pic16f84 and wait byte

    Hello. Mayby yuo can say how i have to do that:
    Me need that portb.0 wait when i in thim send from lpt high level

    I have code

    input portb.0
    low portb.0

    Thanks

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    Irmus>>Hello. Mayby yuo can say how i have to do that:
    Me need that portb.0 wait when i in thim send from lpt high level

    I have code

    input portb.0
    low portb.0
    <<

    Ok, I am trying to understand what you are saying. I hope that I am correct.

    You want Portb.0 to make the PIC chip wait until a signal comes?

    SleepPin var Portb.0
    while SleepPin=High
    Wend

    This will cause the chip to wait until PortB.0 goes low... then the
    chip will continue on. Sorry if this is not what you want.


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks! It work! How me this do:
    I have 8 bits from lpt (impuls) 10011010 how me get hex from impuls , mayby use pulsein command?

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


    Did you find this post helpful? Yes | No

    Default

    you want receiuve them serial or parrallel ???

    if it's parrallel.

    this example use all the 8 pins from PORTB. PORTA.0 is the receive acknoledge pin

    SleepPin VAR PORTA.0
    RParrallel VAR BYTE


    while SleepPin=High
    Wend
    RParrallel=PORTB

    vallue is store into RParrallel.

    if you want to receive in serial use SERIN statement. The following will receive data from PORTB.0 pin. I assume you have an MAX232 between PC and PIC

    Rserial VAR BYTE

    SERIN PORTB.0,4,Rserial

    in case you don't have any MAX232 between PIC and PC use

    SERIN PORTB.0,0,Rserial

    the above assume that you use 2400 baud. In case baudrate is different be sure to have the right crystal to be able handle your specific baudrate. 20MHZ crystal is suitable for 9600 serial comms.

    regards
    Steve

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

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    Irmus>>Thanks! It work!<<

    Great! I am happy that it work for you.

    Irmus>> How me this do:
    I have 8 bits from lpt (impuls) 10011010 how me get hex from impuls , mayby use pulsein command?<<

    Your LPT port... Is it a Serial Port? or Parallel Port?

    If it is Serial, you may want to use SERIN or use a built in USART. If It is a parallel, YOu will need a chip with a 8 pin Port (like portb of most chips). you will wire up your data pins directly to the portb. and send/receive 8 bits at a time.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  6. #6
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    I using LPT port SPP mode

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


    Did you find this post helpful? Yes | No

    Default

    Steve

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

  8. #8
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    I now how work lpt but i dont now how from 10011001 make hex in the pic

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


    Did you find this post helpful? Yes | No

    Talking

    see my post few lines above...
    Steve

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

  10. #10
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    Irmus>>>I now how work lpt but i dont now how from 10011001 make hex in the pic<<

    Mister_e gave you some excellent code for doing this.

    what happens with Mister_e's code, when data is sent via Parallel port to PortB, it is *already* in Hex format!...

    Mister_e's code:

    RParrallel VAR BYTE

    while SleepPin=High
    Wend
    RParrallel=PORTB

    RParallel will have your 10011001 value...
    the hex value is 99. (split your data into 2 groups of 4)
    MSB LSB
    10011001 = 1001 1001
    = 9 9

    Hex=99

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  11. #11
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    I dont now how to say!!!!
    I read one bit from lpt after next - until 8 . How this bits conect to one , in one variable?

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


    Did you find this post helpful? Yes | No

    Default

    with my code you'll read 8 bit in one operation


    you must connect DB25 b0-b7 to input PORTB b0-b7
    Steve

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

  13. #13
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    Irmus>>I dont now how to say!!!!
    I read one bit from lpt after next - until 8 . How this bits conect to one , in one variable?<<

    Ok...SPP is using a Parallel connection... You read all 8 bits at once. You can do this with Portb of most PIC chips. This is the Code the Mister_e gave you, and I have been trying to explain. You told us that you are using SPP (standard Parallel Port). In SPP, you read *all* 8 bits at a time.

    Now, you are telling us you are reading 1 "bit" at a time. this is not SPP. This is serial communication.

    Mister_e gave you some code on Serial communication too. Using SERIN.

    Mister_e's code.

    SERIN PORTB.0,0,Rserial

    this command will automatically take your eight bits and put them into Hex format. that format will be the variable Rserial.

    So Rserial will have the value "10011001" or hex 99.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  14. #14
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    But this EPP mode , i using SPP

  15. #15
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    But this EPP mode , i using SPP


    Ok, lets add another variable then...

    Bit14 Var byte (bits1-4)
    Bit58 Var Byte (bits 5-8)
    RParrallel VAR BYTE

    while SleepPin=High
    Wend

    Bit58=PORTB '(receive MSB)
    while SleepPin=Low 'wait until pin goes high
    Wend
    while SleepPin=High 'wait until pin goes low to transmit new data
    Wend
    Bit14=PORTB

    RParrallel=Bit58
    RParrallel=RParralel<<4 'shifts the bits over
    RParrallel=RParrallel +Bit14
    LCDout RParrallel

    What this does, is read the 1st 4 bits, stores it in a variable
    reads the next 4 bits and stores it in another variable.
    then adds them together to the final result. a couple of problems here...

    1. I don't know if they transmit the MSB first or the LSB first.

    I am not sure if the above code will work for you. I have no way of testing it out.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  16. #16
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    Yuo mayby dont understand what i want to say.
    I read bit 1 in the pic from lpt , i wait next bit i get him and until 8,
    how all bits conect to one byte, example in hex $D5 and store in Eprom. How store in Eprom i now but how with bits? Help
    Thanks

  17. #17
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Irmus,

    Sorry about misunderstanding you...

    Irmus>>Yuo mayby dont understand what i want to say.
    I read bit 1 in the pic from lpt , i wait next bit i get him and until 8,
    how all bits conect to one byte, example in hex $D5 and store in Eprom. How store in Eprom i now but how with bits? Help
    Thanks<<

    Reading one bit at a time through 1 pin, you use Serin, or Serin2 with the correct baudrate. These commands will automatically read 8 bits for you and put them in hex format.
    Reading 8 bits at a time works teh same way...just read the entire port.

    Reading 4 bits at once, and combining two 4 bits has been given to you. The only thing I can think of that has not been given to you is a non-compatible serial type of communication. so I am sending you this kind of serial communication.

    Ok, I am going to try again... a different way....I am sorry if the code we have given you is not the correct code, or what you are looking for. We are trying our best.

    SleepPin VAR PORTA.0
    HexVal var byte

    counter var byte

    Loop:
    HexVal=0; 'initialize to zero
    for counter=0 to 7
    while SleepPin=High
    Wend
    HexVal=PORTB.1 'or whatever pin you receive data.
    HexVal=HexVal<<1
    while SleepPin=Low 'allows time to reset sending pin.
    Wend
    next counter

    LCDout HexVal
    goto Loop:
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

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


    Did you find this post helpful? Yes | No

    Default

    Yuo mayby dont understand what i want to say.
    I read bit 1 in the pic from lpt , i wait next bit i get him and until 8,
    how all bits conect to one byte, example in hex $D5 and store in Eprom. How store in Eprom i now but how with bits? Help
    Thanks

    maybe i'm dumb to write it but...

    1 bit : 1 element
    1 BYTE = 8 bits = 8 element
    1 WORD = 2 BYTE = 16 Bits = 16 elements.


    D5 hexadecimal = 1 byte = 8 bits = 213 in decimal value = 11010101 in Binary value

    you're using SPP=Standard Parrallel Port.

    so if you send to LPT port D5 = 213 decimal = 11010101 binary you will send the 8 bits, 1 byte , D5 in one task to LPT port.

    this is why you must use:

    DataFromLPT VAR BYTE ; 8 bits
    PICPortPinsToReceiveFromLPT VAR PORTB

    start:
    DataFromLPT=PICPortPinsToReceiveFromLPT


    After receiving D5 from your PC DataFromLPT variable = D5 = 11010101 bin =213 decimal

    But maybe you want to receive 8 BYTES and to store them into one variable, in this case you must use ARRAY.

    the following will receive 8 BYTES from LPT and store it into My8BYTES array

    SleepPin VAR PORTA.0

    RParrallel VAR BYTE
    My8BYTES VAR BYTE[8]
    Loop VAR BYTE

    for loop=1 to 8
    while SleepPin=High
    Wend
    RParrallel=PORTB
    My8BYTES[loop]=RParrallel
    next


    Maybe i'm totally out of what you're asking but... TELL ME what i'm missing. i really want to help but sometime i may be wrong in the way i understand your question... maybe caused by my french native language

    Don't be afraid to reply

    regards
    Steve

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

  19. #19
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Steve,

    Steve>>Maybe i'm totally out of what you're asking but... TELL ME what i'm missing. i really want to help but sometime i may be wrong in the way i understand your question... maybe caused by my french native language <<

    Yes, sometimes language barriers are a problem. But IMO that is what makes this site so special. Melanie, Ralph, You and everyone else have been so patient to help me and others... On some of the simplistic things, to the difficult. But at least everyone tries their best to help out and support each other to the best of their ability..even when the answers were not quite the correct answer to the question because of langauge barriers.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  20. #20
    irmus's Avatar
    irmus Guest


    Did you find this post helpful? Yes | No

    Default

    Hello!
    I have code

    baitas var byte

    baitas = $80
    baitas = baitas or $20
    write 0,baitas

    Why in the eprom FF, must be $A0
    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    must you this line instead

    baitas = baitas | $20

    OR is logical operation..(IF THEN ELSE)

    | is a bitwise operation
    Steve

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

Similar Threads

  1. communication between pics
    By meyou in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th August 2004, 03:32
  2. Pic16f84 ---> Pic16f628
    By xak in forum Off Topic
    Replies: 1
    Last Post: - 6th July 2004, 08:25

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