confused problem with interrupt in a working program


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    9600 might be a bit fast for 4MHz. So an adjustment there could be in order.

    Let work on the interrupt problem first.
    The below code has a push button on PORTB.0. PORTB.0 is pulled LOW with an external 10K.
    I have an LED on PORTD.2 for testing with a 470 to the zero rail.
    Using SEROUT2 so a level converter (MAX232) is not needed at this time.

    See if you can make this work and then we can play with the hardware serial and level converters.

    Code:
    '#####################
    '16F877A
    DEFINE OSC 20
    '####################
    @ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF &_BODEN_OFF
    I	VAR	BYTE
    ON INTERRUPT GOTO MACINT
    INTCON = %10010000
    
    LOOP:
    HIGH PORTD.2
    SEROUT2 PORTC.6,16468,["PUSH ME !!!",10,13]
    PAUSE 100
    GOTO LOOP
    
    '############################################
    DISABLE
    MACINT:
    IF PORTB.0 = 1 THEN
    FOR I = 1 TO 10
    HIGH PORTD.2
    PAUSE 150
    LOW PORTD.2
    PAUSE 150
    SEROUT2 PORTC.6,16468,["MACKRACKIT",10,13]
    NEXT I
    ENDIF
    INTCON.1 = 0
    RESUME
    ENABLE
     'THE ABOVE WILL ALSO DEBOUNCE THE SWITCH
    '#############################################
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    9600 baud run perfect @4MHz with the hardware USART (0.16% error), however may suffer with SEROUT, SEROUT2, in this case DEBUG is recommended if you don't want to use the Hardware USART.
    Steve

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

Similar Threads

  1. urgent: interrupt problem please help
    By cwmaddy in forum General
    Replies: 4
    Last Post: - 21st July 2009, 19:14
  2. USART interrupt in PIC16F877A
    By amindzo in forum General
    Replies: 7
    Last Post: - 26th August 2006, 18:51
  3. Simple Interrupt Program
    By eoasap in forum General
    Replies: 5
    Last Post: - 28th October 2005, 16:22
  4. Interrupt Problem
    By FrankM in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 20th June 2004, 15:53
  5. interrupt problem....need help urgently
    By johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2004, 17:34

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