Loading ...
Sorry, an error occurred while loading the content.
 

Re: 16F877a settings port C and D

Expand Messages
  • Hansv
    Hi all, I have spent an evening to do tests on 2 PCB s and pic s with Jallist and Jallib. I ll try to describe the mistakes I have found: In Bert s
    Message 1 of 12 , Feb 1, 2013
      Hi all,
      I have spent an evening to do tests on 2 PCB's and pic's with Jallist and Jallib.
      I'll try to describe the "mistakes" I have found:
      In Bert's environment the definition HIGH port part is not supported so I have to define it pin by pin. I have to switch off the USART function of C_high because it is set at the basic include Also I have to write define PORT_C_direction(Bert) and not PORTC_direction (JALLIB)
      Then I found that the command port_C_high (or PORTC_high) = HIGH, only set the first pin high. Here I have to set 0B_1111.
      I finally tried to use the latest Bert's book (Piccolino) files but therefore I have to change the compiler settings.(I did not order the piccolino)Since this is brandnew for me I am not going to make changes in all these predefined elements.
      The doubt I had for the strange results of pin D4 are still there, I have no idea why I did not find this again during my tests
      Now I am going to see what I can do with my searching results.
      (My sugar is in the glass sugarpot beside the coffeemaker)
      Regards
      Hans





      --- In jallist@yahoogroups.com, "Hansv" wrote:
      >
      > Hi all,
      > I have used the mentioned way for a long time, but now i found these problems.
      > In Bert's files I have found the switch-off command for the usart on portC-high. On others I have to define pin by pin and also write/read pin by pin. Somewhere I have problems with the Port High calls. Maybee it is caused by having installed Jallist/jallib older and newer versions on my PC.
      > The only pin I cannot use now is pin D4 so maybee this port is broken.
      > I'll see to get things clear. Now it's like my grandmothers kitchen where you can find the sugar in the coffee-tin labeled with choco.
      > Anyway thanks for your reactions.
      > Hans
      >
      >
      > --- In jallist@yahoogroups.com, Patrick wrote:
      > >
      > > Hans,
      > >
      > > You can change the port direction during your program it's just up to
      > > you to know what you do!
      > >
      > > Patrick
      > >
      > >
      > > Le 31/01/2013 16:32, Hansv a écrit :
      > > >
      > > > Forgot to say: port_D_high must be used as data-out as well, switched
      > > > during the running program.
      > > >
      > > > --- In jallist@yahoogroups.com ,
      > > > "Hansv" wrote:
      > > > >
      > > > > I have read the datasheet, slept with it and dreamed about it but
      > > > the result is a nightmare!! Please help!. On a 16F877a I will use port
      > > > C_high as normal data out and D_high as normal data in so I have to do
      > > > something with PORTC,PORTD, TRISC and TRISD but what??
      > > > >
      > > >
      > > >
      > >
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      >
    • Rob Hamerling
      Hi Hans, ... From time to time you (we all?) may have to go back to basics! ;-) ... The compiler warns you when you try to assign a wide value to a smaller
      Message 2 of 12 , Feb 1, 2013
        Hi Hans,

        On 1-02-13 09:31, Hansv wrote:

        > I have spent an evening to do tests on 2 PCB's and pic's with Jallist and Jallib.

        From time to time you (we all?) may have to go back to basics! ;-)

        > Then I found that the command port_C_high (or PORTC_high) = HIGH,
        > onlyset the first pin high. Here I have to set 0B_1111.

        The compiler warns you when you try to assign a 'wide' value to a
        smaller variable, but not the other way around (because in the latter
        case there is no danger of loosing information).
        And you are not the first to discover (after a long search) that
        true/false, input/output, high/low, true/false, enabled/disabled are bit
        constants! Not surprisingly these have effect on only one bit or pin
        when you try to assign it to a nibble, byte, word, etc.


        > The doubt I had for the strange results of pin D4 are still there, I
        > have no idea why I did not find this again during my tests

        Cannot this be explained by inappropriate direction settings (using
        PortD_high_direction = INPUT/OUTPUT in stead of ALL_INPUT/OUTPUT)?

        One source of confusion is mixing or switching between Jallib and Bert's
        setup. There are some subtile differences between these library sets!
        You better choose for one or the other for all your projects.

        Regards, Rob.

        --
        R. Hamerling, Netherlands --- http://www.robh.nl
      • Bert van Dam
        Hi Hans, ... Correct, but you can easily make your own procedure for this. ... the basic include That s a bit of a hassle, and it s not needed. See, you don t
        Message 3 of 12 , Feb 1, 2013
          Hi Hans,

          > In Bert's environment the definition HIGH port part is not supported

          Correct, but you can easily make your own procedure for this.

          > I have to switch off the USART function of C_high because it is set at
          the basic include

          That's a bit of a hassle, and it's not needed. See, you don't need to use
          the existing ports, you could create a virtual port and use pins from
          different ports. This is an example program that defines a virtual port
          consisting of three pins from three different ports, Connect LEDs to each
          of these pins and the program displays a binary counter. It's for the
          Piccolino but it will work with any PIC supported by the JAL books.

          include 16f887_bert_piccolino

          procedure virtualport_set_output is
          pin_c2_direction = output
          pin_d2_direction = output
          pin_b0_direction = output
          end procedure

          procedure virtualport_write(byte in data) is
          pin_c2 = data & 1
          pin_d2 = data & 2
          pin_b0 = data & 4
          end procedure

          virtualport_set_output

          var byte t

          forever loop
          virtualport_write(t)
          t=t+1
          if t==8 then t=0 end if
          delay_1s(1)
          end loop

          You can define the virtual port any way you like. In this example it is
          three bits wide, but it could be 4, 8, 16, anything you want. Use a few
          I/O expanders and it could 64 bits wide :-)

          Have fun,
          Bert


          www.vandam.tk


          [Non-text portions of this message have been removed]
        • Hansv
          ... I went back to the older files and indeed I found this error which i had corrected later on while doing my tests.Therefor I could not reproduce this later
          Message 4 of 12 , Feb 1, 2013
            --- In jallist@yahoogroups.com, Rob Hamerling wrote:
            >
            >
            > Hi Hans,
            >
            > On 1-02-13 09:31, Hansv wrote:
            >
            > > The doubt I had for the strange results of pin D4 are still there, I
            > > have no idea why I did not find this again during my tests
            >
            > Cannot this be explained by inappropriate direction settings (using
            > PortD_high_direction = INPUT/OUTPUT in stead of ALL_INPUT/OUTPUT)?
            >
            I went back to the older files and indeed I found this error which i had corrected later on while doing my tests.Therefor I could not reproduce this later on.Great!



            > One source of confusion is mixing or switching between Jallib and Bert's
            > setup. There are some subtile differences between these library sets!
            > You better choose for one or the other for all your projects.
            >
            Rob I am just a LEGO builder, I like the collors and the stones but have just a very small idea how they are produced.
            I realise the risc I am playing with two systems (now 3???) on my PC but on one side I love the Dutch and practical examples form Bert's books (I had to buy a second one because the first one is already worn out) and on the other side I have used a lot of the excellent JALLIB examples.
            (By the way is there a JALLIB sample for serial_SW with the connected Wisp?)
            So I stay with my legs split on each side of the ditch.
            Regards
            Hans
          • Hansv
            Hi Bert, I make a print from your reaction for study later on, Thanks regards Hans
            Message 5 of 12 , Feb 1, 2013
              Hi Bert,
              I make a print from your reaction for study later on, Thanks
              regards
              Hans

              --- In jallist@yahoogroups.com, Bert van Dam wrote:
              >
              > Hi Hans,
              >
              > > In Bert's environment the definition HIGH port part is not supported
              >
              > Correct, but you can easily make your own procedure for this.
              >
              > > I have to switch off the USART function of C_high because it is set at
              > the basic include
              >
              > That's a bit of a hassle, and it's not needed. See, you don't need to use
              > the existing ports, you could create a virtual port and use pins from
              > different ports. This is an example program that defines a virtual port
              > consisting of three pins from three different ports, Connect LEDs to each
              > of these pins and the program displays a binary counter. It's for the
              > Piccolino but it will work with any PIC supported by the JAL books.
              >
              > include 16f887_bert_piccolino
              >
              > procedure virtualport_set_output is
              > pin_c2_direction = output
              > pin_d2_direction = output
              > pin_b0_direction = output
              > end procedure
              >
              > procedure virtualport_write(byte in data) is
              > pin_c2 = data & 1
              > pin_d2 = data & 2
              > pin_b0 = data & 4
              > end procedure
              >
              > virtualport_set_output
              >
              > var byte t
              >
              > forever loop
              > virtualport_write(t)
              > t=t+1
              > if t==8 then t=0 end if
              > delay_1s(1)
              > end loop
              >
              > You can define the virtual port any way you like. In this example it is
              > three bits wide, but it could be 4, 8, 16, anything you want. Use a few
              > I/O expanders and it could 64 bits wide :-)
              >
              > Have fun,
              > Bert
              >
              >
              > www.vandam.tk
              >
              >
              > [Non-text portions of this message have been removed]
              >
            • Bert van Dam
              Hi Hans, ... Two. The Piccolino uses the exact same Starterpack as all the other JAL books. Have fun, Bert www.vandam.tk
              Message 6 of 12 , Feb 1, 2013
                Hi Hans,

                > I am just a LEGO builder, I like the collors and the stones

                :-)

                > I realise the risc I am playing with two systems (now 3???)

                Two. The Piccolino uses the exact same Starterpack as all the other JAL books.

                Have fun,
                Bert


                www.vandam.tk
              Your message has been successfully submitted and would be delivered to recipients shortly.