Flash an LED 10F200 Tutorial

Discussion in 'Embedded Systems and Microcontrollers' started by PICNewbee, Aug 12, 2017.

  1. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Baseline PIC Assembler, Lesson 2: Flash an LED Page 9
    In lesson 1, we made GP1 high, and left it that way. To make it flash, we need to set it high, then low, and then repeat. You may think that you could achieve this with something like:
    flash
    movlw b'000010' ; set GP1 high
    movwf GPIO
    movlw b'000000' ; set GP1 low
    movwf GPIO
    goto flash ; repeat forever
     
  2. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    There's the text from tutorial at the first new part in Lesson 2

    Note. This code will be corrected next in lesson..

    I will look in 10F200 datasheet.

    Is GPIO 8 bits wide?

    What comes after this is ROUGH!
     
  3. MaxHeadRoom

    Expert

    Jul 18, 2013
    18,797
    5,849
    It's only an 8 pin chip!!
    GPIO-0 to 3.
    So 4 I/O.
    Max.
     
  4. jayanthd

    Active Member

    Jul 4, 2015
    902
    79
    2 pins go for VDD and VSS.
     
  5. be80be

    AAC Fanatic!

    Jul 5, 2008
    1,897
    394
    Well that would work if the clock was ticking at about half a second a tick
    but at 4 mhz you'll never see it change a scope can
    Code (Text):
    1. flash
    2. movlw b'000010' ; set GP1 high
    3. movwf GPIO
    4. movlw b'000000' ; set GP1 low
    5. movwf GPIO
    6. goto flash ; repeat forever
    Need a call delay
    Code (Text):
    1. flash
    2. movlw b'000010' ; set GP1 high
    3. movwf GPIO
    4. Call delay
    5. movlw b'000000' ; set GP1 low
    6. movwf GPIO
    7. Call delay
    8. goto flash ; repeat forever
     
  6. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Max!

    Datasheet says GPIO is a 8 bit register.

    Only 'low order' bits are used.

    Bits 7 through 4 are 'unimplemented'.

    Today's new word!

    movlw b'000010'

    Why are 6 bits being moved?

    Just good programming practice?
     
  7. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Bebe!

    You're jumping ahead!

    Wait until you see what comes next!

    This is one tough tutorial.
     
  8. jayanthd

    Active Member

    Jul 4, 2015
    902
    79
    Code (Text):
    1.  
    2. asm bsf
    3. asm bcf
    4.  
    can be used to set and clear bit of a file register.
     
  9. be80be

    AAC Fanatic!

    Jul 5, 2008
    1,897
    394
    It's a 6 pin chip that comes in a 8 pin package
    Using 6 bit's is just lazy writing. Not good anything.
    Just makes it easy to make a mistake.
    The chip is 8 bit writing 0b000000 or 0b00000000 takes one byte
    writing 0b000000 saves nothing but 2 key stokes on the key pad and
    It will get you sooner or later.
     
  10. MaxHeadRoom

    Expert

    Jul 18, 2013
    18,797
    5,849
    If using the MOVLW with binary it would be customary to use b'00000010'
    Although the other will work.
    Max.
     
  11. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Bebe and Max!

    Okay. So writing all 8 bits is more the good programming practice. Got it!

    What does GPIO do?

    High and low?

    Does that mean internally the PIC is opening and closing the circuit for regulated 5 volts for that pin?

    Making pin an output was handled earlier.

    Tutorial modifies first lesson source code for this second lesson.

    I just didn't post that.
     
    Last edited: Aug 12, 2017
  12. jayanthd

    Active Member

    Jul 4, 2015
    902
    79
    TRISIO register configures the PORT as Input or Output PORT. GPIO menans General Purpose IO register. It holds the value of the PORT if PORT is configured as input or it sets the PORT state (0 or 1) if PORT is configured as an output port.
     
  13. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Jay!

    PORT?

    Let me look at the tutorial and the datasheet again.

    I do not remember PORT.

    You have all been warned about what the tutorial does next!:)

    Yes. It does put a delay in but that is not the really fun part.

    I am going to take a break and dive into that later.
     
  14. MaxHeadRoom

    Expert

    Jul 18, 2013
    18,797
    5,849
    A GPIO PORT (General Purpose Input/Output Port) is one way how you get data into the chip, or provide an output!!
    Max..
    ,
     
  15. jayanthd

    Active Member

    Jul 4, 2015
    902
    79
    A PORT is the hardware which is used for interfacing Input and Output devices like buttons, Leds, etc,...

    A PORT has TRISIO and GPIO registers associated with it. It might have other registers like ANSEL, ANSELH, ANSELx in other PIC devices for configuring the PORT or PIN (bits of a PORT) as analog pins.
     
  16. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Max and Jay!

    Datasheet lists PORT registers on Page 21. 10F200 datasheet.

    TRISGPIO

    GPIO

    Then throws in

    OPTION

    STATUS

    Okay. Now it's breaktime.
     
  17. MaxHeadRoom

    Expert

    Jul 18, 2013
    18,797
    5,849
    Then you have high resistance internal pull ups option.
    But better not go there! :eek:
    Max.
     
  18. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Max!

    'But better not go there!'

    That's what is going on with me doing this.

    Each little step forward is bringing up questions.

    Hard to tell what is important and what isn't at this stage of the game.

    Will start at this nice and fresh tomorrow.
     
  19. be80be

    AAC Fanatic!

    Jul 5, 2008
    1,897
    394
    Baby chip got only gpio big chips got lots ports.
    The port is like a programmable transistor well that's what it is
    10f200.png
    The 10f200 has little to nothing to use and to do a lot with it is not as easy as one would think cause of
    hardware limits.
    256 fash 16 bytes sram 4 i/o 1 8 bit timer
    Not much to work with there.
     
  20. PICNewbee

    Thread Starter Member

    Mar 31, 2017
    355
    14
    Thank you Bebe!

    Yes. I did see the schematic of the hardware for a port.

    That fits my definition of a 'I am not going to go there.'

    Okay. Get ready for part of tutorial here!
     
Loading...