Surprising 16F628 / 20


Closed Thread
Results 1 to 12 of 12

Hybrid View

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

    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
    967


    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,653


    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
    967


    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,653


    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 " !!!
    *****************************************

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 : 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