Surprising 16F628 / 20


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614

    Question Surprising 16F628 / 20

    I tried to program a ... simple stupid blinking light ... and it doesn't work ... as it should !!!

    Code:
    '******************************************************************************
    'Configuration
    '******************************************************************************
    
    @	__CONFIG  _BODEN_ON &_CP_OFF & _PWRTE_ON & _WDT_ON & _LVP_OFF & _MCLRE_ON  & _INTRC_OSC_CLKOUT
    
    	CMCON	= 7
    	VRCON	= 0	
    
    ...
    
    '*****************************************************************************
    'Initialisation des ports
    '*****************************************************************************
    
    	PORTA   = 0
    	PORTB   = 0
    
    	TRISA = %00000111
    	TRISB = %00000000
    
    ...
    
    '******************************************************************************
    oubli: ' Boucle d'arret si oubli cavalier
    '******************************************************************************
    
    	PORTB.0 = 1
    	PAUSE 200
    	PORTB.0 = 0
    	PAUSE 200
    
    	GOTO Oubli
    Doesn't work


    But That snippet works fine :

    Code:
    ( same as previous )
    
    ...
    
    '******************************************************************************
    oubli: ' Boucle d'arret si oubli cavalier
    '******************************************************************************
    
    	HIGH PORTB.0 
    	PAUSE 200
    	LOW  PORTB.0
    	PAUSE 200
    
    	GOTO Oubli
    The load on PORTB.0 is a simple LED drawing 12 mA ...

    Has someone an idea ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Alain

    What do you mean - Doesn't work. Can you elaborate your statement? Is the LED always on/off?
    The ellipses before Oubli - is there something that modifies your TRISB in there?

    When you do HIGH / LOW to a pin, PBP also writes the TRIS bit for the pin to the direction you need.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi, Jerson

    Halas, there are no TRIS mods in the whole program ( including PbP commands ).

    Just reading 3 EEPROM locations to verify if the device is ( application ) programmed or not.

    add to that a BUTTON command to verify, if EEPROM unprogrammed, if the programming jumper has been inserted ...


    Code:
    	TRISA = %00000111
    	TRISB = %00000000
    
    
    '******************************************************************************
    'Lecture des valeurs en EEPROM
    '******************************************************************************
    
    
    	READ 1,dureeprog
    	READ 2,side
    	READ 3,neutre
    
    	IF ( neutre <> 255 ) AND( dureeprog <> 255 ) THEN start
    
    '******************************************************************************
    ' Vérification Présence Cavalier si premičre programmation
    '******************************************************************************
    
    	Delay = 0
    	BUTTON ModProg,0,255,0,delay,1,Mesurepro
    
    '******************************************************************************
    oubli: ' Boucle d'arret si oubli cavalier
    '******************************************************************************
    ...
    as you can see, I just had cut those "unsignificant" lines.

    I've also verified the ASM lines, but nothing noticeable ...



    the strange thing is I had added those lines just past TRISA and TRISB, to verify PortB ( same LED load + 270 Ohms on each PortB output ) ...

    Code:
    '******************************************************************************
    'Verification PORTB
    '******************************************************************************
    
    '	FOR I = 0 to 7
    '	
    '		PORTB.0[i] = 1
    '		PAUSE 300
    '		
    '	NEXT I
    '	
    '	FOR I = 7 to 0 Step -1
    '	
    '		PORTB.0[i] = 0
    '		PAUSE 300
    '		
    '	NEXT I
    and it worked well ...


    I've already seen Port outputs not working , like here, but it was when driving large capacitive loads ( 3.5 µF between output and ground !!! ).

    Solution had been using HIGH and LOW ... like here.


    But, Here, it's the first time I see that with LEDs as loads ...

    so, I know what to do ... but really don't understand why !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Read-Modify-Write issues?

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Alain

    I'm not really sure what to make of it. What is the state of LED? On or Off?

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi, Jerson

    PORTB.0 = 1 : Led do not work

    HIGH PORTB.0 : Led works fine


    Hi, Ski

    I verified the ASM ... doesn't read anything at all ,here.

    Code:
    PORTB.0 =  BSF PORTB,0
    
    HIGH PORTB.0 =  BSF PORTB,0
                           BSF STATUS, 5
                           BCF PORTB,0
    
                        **Next ASM command** MOVLW 0xC8 ( Pause duration )
    
                           BCF STATUS, 5
    so, the only "surprising thing" is it writes PAUSE duration in W while addressing page 1 ... but I do not think it should cause any trouble ... I suppose it works like that not to toggle Page twice, if staying on page 1 !

    I'll try the program with XTAL clock ( it's the first time I use INTRC with this snippet ...) ever has worked well till yesterday ... just to see.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Alain,

    My guess would also be read-modify-write. Try increasing the pause time from 200 to
    1000 in the first version you posted that isn't working. Does it work with the longer
    pause?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I had something similar.

    And even tough PORTB.0 = 1 or 0 did not work, interestingly PORTB.0 = PORTB.0 ^ 1 worked.


    ??
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  9. #9
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    another thought ...

    try removing the LEDs and watching the pins with a scope or DMM. If no load works then add more decoupler / filter caps.

    just my 1 cent
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  10. #10
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Alain

    Just thinking aloud. I am assuming the 16f628 / 20 in the subject means you are thinking it runs at 20MHz or is it something else? The INTOSC for the 628 is 4MHz. Perhaps you have declared 20MHz for OSC like below. Is this a possible cause?

    define OSC 20

    I do remember having faced a problem like this once before, but unfortunately, I cannot recall what it was and in which project. It too had to do with an LED though. All I remember is that I had to write the port twice with a delay between the 2 writes to get it to behave.

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi, Jerson

    It's not a speed issue nor ... I intend to make them run @ 4Mhz !!! ( or so ... the RCINTOSC is somewhat aside the 4Mhz !!! )

    This Pic is just ... 10% under the 4 Mhz !!! ( 136 units for a true 1500 µs pulse ).

    I think we met the same issue ...


    Hi, Bruce

    The Pause time modifying do not change anything.

    Hi, Sayzer

    That's the strange thing ... just the ( let's say ) ASM command doesn't work. A signal rise and fall time issue inside the Pic ???

    Hi, Paul

    Signal is neat and right on the DMM ... only without the Led !


    So, ... I have to try another Pic Sample to confirm !!!



    BTW ... I discovered in MPLAB 8.10 programmer, If you ask for ALL Erase ... The EEPROM is NOT Erased, and you must explicitly ask for FF Writing ...

    same issue in the toolbar's "Erase Flash Device" ...

    to be verified for other processors ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    >>If no load works then add more decoupler / filter caps.

    Sounds like it worked - do you have electrolytic decoupler and ceramic filter caps? Is your power clean? Have you reduced ground loops?

    Strange indeed to be sensitive to 12mA load switching ....

    Interested to know how it turns out
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. INT2 anomaly in DT_INTS-18??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th February 2010, 20:07
  2. capture/repeat data ?
    By Sam in forum Serial
    Replies: 44
    Last Post: - 27th November 2006, 03:19
  3. A little DTMF help
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 48
    Last Post: - 30th May 2006, 01:31
  4. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  5. SERIN2 not working with 16F628
    By d1camero in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 20:37

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