help!!!


Closed Thread
Results 1 to 17 of 17

Thread: help!!!

  1. #1
    Join Date
    Dec 2005
    Posts
    12

    Lightbulb help!!!

    hey guys i m using the PIC16F84 with 9600 baudrate, no stop bits.
    i just need a code using picbasic pro that takes 8 bites from the port A0 of the PIC and outpot them as bits on b0 through B7
    the microcontroller is acting like a serial to parallel converter!

    so can u plz provide me with the code?

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


    Did you find this post helpful? Yes | No

    Default

    are your sure of you protocol?
    i m using the PIC16F84 with 9600 baudrate, no stop bits
    What about...
    Code:
    TRISA=255
    TRISB=0
    DEFINE DEBUGIN_REG PORTA  ' Serial data come in 
    DEFINE DEBUGIN_BIT 0      '     PORTA.0
    DEFINE DEBUGIN_MODE 0     ' true driven mode
    DEFINE DEBUG_BAUD 9600    ' 9600 BAUD
    DataIn var byte
    
    START:
          DEBUGIN DataIn
          PORTB=DaraIn
          goto start
    be sure of your Serial Mode => Inverted or not
    Be sure you also define your OSC speed
    Last edited by mister_e; - 9th January 2006 at 23:13.
    Steve

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

  3. #3
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help!!

    i m using these settings "9600,N,8,1"

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


    Did you find this post helpful? Yes | No

    Default

    OK so 9600 Bauds, No Parity, 8 databits, 1 stop bit. The above code should work depending how your data is sent and how you interface your PIC to the external world.

    You may need some Modifiers => look the DEBUGIN section
    You may need to change the Serial mode from True to inverted.

    Keep us inform
    Steve

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

  5. #5
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help!!

    i wrote this code but it s not working! so any ideas


    N2400 con 0 'Set Serial mode
    T9600 con 2 ' Set serial mode Baud Rate (T = True)
    VARB0 var BYTE 'Define a variable VARB0 of type byte
    TRISA=$FF 'Set port A to 1 (input)
    TRISB=$00 'Set port B to 0 (output)

    loop:
    Serin PORTA.0,2,VARB0 ' B0 = input character Input the data serially from port A, pin0, at a Baud rate of 9600,
    PORTB = VARB0 'send the data in VARB0 to PORTB (output)

    PAUSE 50 'delay 50ms

    Goto loop ' Forever repeat the loop

    END 'end the program

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


    Did you find this post helpful? Yes | No

    Default

    Where your data come from?
    Are you using an inverter like MAX232 ?
    Did you connect the PIC Supply GND to the External world GND?
    What is your crystal speed?
    Did you set your config fuse properly?
    Did you tied the MCLR pin to VCC?
    Any schematic or picture of your prototype?
    Steve

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

  7. #7
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help!

    i did used the max232
    i m using 4MHZ oscillator
    my data come out from the rs232

    below is my attachement of the schematic
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    O.K. So How your data is send? I mean... when you send 100 is this the numeric expression 1,0,0 or the ASCII character (wich is "d")?

    can your try

    Serin PORTA.0,2,#VARB0

    What are you using to send your data? Hyperterminal? MCS serial communicator or else?

    4 MHZ crystal is maybe not enough... look in the SERIN/SEROUT section... there's some warning on that. DEBUGIN should work better and provide a wider 'modifier' range.
    Steve

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

  9. #9
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    as far as I understand 4MHz is not enough for the 9600 baud. Page 135 in the PBP manual. Second to last paragraph.

  10. #10
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help

    well i m using a vb application to send the byte and it is sent as hexadecimal

    well i ll look for the 4 MHZ oscillator for such a high bauderate.

  11. #11
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help

    hey guys about the 4MHZ not enough for the 9600 baude rate r u sure about it
    ?

  12. #12
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Lightbulb help

    i mean is there anything wrong with the pbp code i attached above?

  13. #13
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    I am learning about this too. I have some problems my self in a different area, but as stated in the manual:

    " An oscillator speed faster than 4MHz may be required for reliable operation at 9600 baud and above."

    That is only why I said something about it. I remember seeing it and thought that it could help with suggestions. Good Luck.

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


    Did you find this post helpful? Yes | No

    Default

    i can't safely said it will not work @4MHZ, but by the warnings...

    Why not using DEBUG instead as suggested before WICH WILL FOR SURE provide a faster baudrate even @4MHZ
    Steve

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

  15. #15
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default HElp!

    thx for ur help

  16. #16
    Join Date
    Dec 2005
    Posts
    12


    Did you find this post helpful? Yes | No

    Default help!!

    TRISA=255
    TRISB=0
    DEFINE DEBUGIN_REG PORTA ' Serial data come in
    DEFINE DEBUGIN_BIT 0 ' PORTA.0
    DEFINE DEBUGIN_MODE 0 ' true driven mode
    DEFINE DEBUG_BAUD 9600 ' 9600 BAUD
    DataIn var byte

    START:
    DEBUGIN DataIn
    PORTB=DaraIn
    goto start


    does this code for 16F84 plays the role of a serial to parallel converter?

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


    Did you find this post helpful? Yes | No

    Default

    it's suppose too, depending how the data is send by the external world. If the external device send the character 128... you send 128 to the port. BUT if the external device send the string 128... if you're lucky, you'll send 1, then, 2, then 8 at the output. SO all depend of the external device.

    What are your results as now?
    Did you tried different modifiers? (DEC, HEX....)
    Steve

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

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