INTCON and 16F628


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Location
    Bosnia
    Posts
    3

    Unhappy INTCON and 16F628

    I started to do some GSM controller project with the PIC, as a school project. But I constantly arises a problem that my pic "goes crazy". At end I think it's problem with the Interrupts. I had connected a LED on RB.0 that is a INT input, and when i set the RB.0, in the program, on 1 the PIC start to act crazy (LED's blink, and he send some partial informations trought the USART). I tried to not set RB.0 on 1 and everything works fine. So I tried to connect the LED on RB.4 (it's a INT input again) and the same problem occurs when i set it to 1. I tried to set the INTCON=0 (INTCON.3, INTCON.4=0) but the problem is still there.

    Here is some example of the PBP code:

    Code:
    DEFINE OSC 8
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h 
    DEFINE HSER_BAUD 9600 
    DEFINE HSER_SPBRG 12
    CMCON = 7
    INTCON=0
    symbol LED1=PORTB.3
    SYMBOL LED2=PORTB.4
    SYMBOL SDA = porta.0
    SYMBOL SCL = porta.1
    DEFINE I2C_SDA PORTA.0
    DEFINE I2C_SCL PORTA.1
    adr VAR BYTE
    ZNAK VAR BYTE [5]
    OUTPUT LED2
    OUTPUT LED1
    adr=20
    
    serial:
    
    hserout ["SERIAL"] 
    
    hserin 3000, serial, [str ZNAK\5]
    pause 100
    HIGH LED1
    PAUSE 1000
    LOW LED1
    
    I2CWRITE SDA, SCL, $A0, adr, [STR ZNAK\5]
    PAUSE 10
    HSERIN [WAIT ("OK")]
    
    GOSUB LDE
    PAUSE 500
    
    HIGH LED2
    PAUSE 2000
    GOTO SERIAL
    LDE:
    
    HIGH LED2 
    HIGH LED1
    PAUSE 1500
    LOW LED2
    PAUSE 1500
    LOW LED1
    HIGH LED2
    PAUSE 1500
    HIGH LED2
    LOW LED1
    PAUSE 1500
    LOW LED2
    RETURN
    
    END
    I hope someone can help me!

    P.S. Sorry for my beeeeeddd english!!!!

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Floating ports and noisy power are 2 BIG reasons for PICs to go crazy. Set your tris registers and Ports in your code to a known state and tie unused pins to VSS or VDD through 10k resistors. Put a .01uf and a 10uf capacitor across the power lines as close to the pic as possible to short the noise there, even a ferrite bead in series with the B+ is helpful too.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    It can't be interrupt as you don't use any in your code.

    As Joe said, check you hardware. Also make sure your config fuses are set for HS_OSC and LVP_OFF. Same goes for MCLR pin.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    If you're doing it on a breadboard, then things can go really bad. Some old breadboard can have such capacitance that may screw your OSC stability.

    Keep wiring short and clean, ground the back plane (if any), and sprinkle few 0.1 uF+10uF tantalum all over will not hurt.
    Steve

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

Similar Threads

  1. LCD problem with 16F628
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 19th September 2016, 08:28
  2. intcon?
    By jonas2 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd September 2009, 11:07
  3. 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