Very wierd problem


Closed Thread
Results 1 to 4 of 4
  1. #1
    jswayze's Avatar
    jswayze Guest

    Default Very wierd problem

    Hi folks,

    I've scratched my head over this one for most of the day and after paring my original program down to the minimal number of lines, I'm still stuck. First, the code:
    Code:
    @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
    
    count1 var word
    
    init:
        count1 = 0
    
    check1:
        if count1 = 0 then high 0
    --------------
        if count1 = 7 then
    high 1
    pause 20
    low 1
        endif
    -------------
        IF count1 = 20 then low 0
         
        if count1 = 100 then
            count1=0
        else
            count1 = count1 + 1
        endif
        
        pause 20                        ' 20 ms increments
        goto check1
    This is essentially an LED flasher where I can control the duration and delay of the flashes but substituting different numbers in the "if count1=" lines. Hopefully it's pretty easy to follow. Initially, ignore the "if count1=7 ... endif" lines.

    When I run this on my 16F628, I expect to see my LED flash at a constant rapid rate. When count1=0, the LED goes on. When count1=20 the LED goes off. When count1=100 we start all over again.

    What actually happens is that as soon as I power up the PIC, I get one flash, a short delay, then the rapid flashes I expect. It's this rogue flash at the beginning that I can't figure out.

    Now about the HIGH 1/LOW 1 lines. I added these in to flash a "debugging" LED when count1 reached certain values. What I found was that, for the first cycle only, count1 was being reset when it reached 6! If I leave the code as shown (IF count1=7), the LED at 0 does it's initial wierd flash before running smoothly. If I change it to (IF count1=6), then I get a flash from BOTH LEDs during the first rogue flash.

    Can anyone offer any explanation to this? After the first errant flash everything runs fine. I just don't get it.

    Thanks for your time,

    Jeff
    Last edited by jswayze; - 15th November 2004 at 03:48.

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


    Did you find this post helpful? Yes | No

    Default

    hummmm. i'm not familiar with those High0, High1.... but PIC16F628 have internal comparator that must be disable pior to acces to those pin...

    CMCON=7

    what is High 1 refer to ... i mean on wich PORT ?

    regards
    Steve

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

  3. #3
    jswayze's Avatar
    jswayze Guest


    Did you find this post helpful? Yes | No

    Default

    HIGH and LOW set PORTB, but looking at the pbp manual, PORTB.0=1 would be a more effecient way to do this.

    Well, I have a strange "fix" to my strange "problem." As it turns out, there is no problem at all. If I unplug and re-plug in the power connector, the LED does just what it is supposed do. So, the problem is generated when I re-program the PIC via the EPIC progammer's ICSP port.

    This is very stange, but at least it ends up working the way its supposed it!

    Thanks,

    Jeff

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


    Did you find this post helpful? Yes | No

    Default

    well that's indeed an strange problem... humm... i always program my PIC in ICSP and never had any problem like this...

    You don't get any error when programming ? can you try MCLR_ON and post results... i'm curious on that problems.

    Maybe some others have an other idea here?
    Steve

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

Similar Threads

  1. Problem with ASM IRQ using FSR0 on PIC18F252
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th March 2008, 20:48
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. wierd problem with 12f629 Need Help Despretly
    By Nadeem in forum Off Topic
    Replies: 1
    Last Post: - 15th June 2005, 20:59

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