interrupt delay setup, please help

Discussion in 'Embedded Systems and Microcontrollers' started by cubi, Mar 27, 2009.

  1. cubi

    Thread Starter New Member

    Mar 27, 2009
    8
    0
    Hi all,
    Could you please give me some hints or code that will do:
    I want the PIC18F to only start running when there is a rising edge interrupt or receiving Rx coming into the chip.
    Thank you!

    cubi
     
  2. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    Do you want to put the processor to SLEEP mode, master cleared or actually powered down?

    You can put it to SLEEP for power conservation and wake it up via WDT wakeup if enabled or an interrupt via INT pin, RB input change or peripheral interrupt.
     
  3. cubi

    Thread Starter New Member

    Mar 27, 2009
    8
    0
    The PIC will be running when I'm done programming in it. But it will do nothing until there is an interrupt on rising edge or Rx at USART. Could you please help me? Thanks
     
  4. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    Whoever does provide help will need to know a couple of things.

    1. A clear statement of your design goal(s).
    2. How far you have progressed on the work yourself.
    3. What language, software and hardware developer tools you are using.
    4. A copy of whatever code or relevant code sections you have written so far.

    Otherwise I can only refer you to the particular PIC18F data sheet which can be downloaded from the Microchip website.

    I'm still not clear whether you actually want to have the processor in SLEEP mode or not. Correct me if I'm wrong, but I think you just want it running in the main loop part of the program awaiting an interrupt from the serial interface, which you then service to do something in the way of a response - say sending data back via the serial port???

    :)
     
  5. cubi

    Thread Starter New Member

    Mar 27, 2009
    8
    0
    yes sir t_n_k,
    Lets assume I have 2 PICs
    My project goal is to check the high input from PORTB pin0. If there is a high input from this pin of PIC 1, the PIC1 will transmit some data to signal the PIC 2 meaning it wants to check the condition of PIC 2 (whether high or low). After PIC 1 has finished its transmission, it will jump back to what it has been doing. After a few seconds, when PIC 2 checks its condition of PORTB pin0, it will send back some data to PIC 1 to inform its condition of PORTB pin0 with PIC1. If PIC 1 receives an interrupt of Rx, it will stop everything and receive the data sent from PIC 2. And the same steps would applied with PIC2.

    I use C program and C18 MPLAB from microchip as a compiler.
    I want the PIC to be interrupt when the is a rising edge on PORTB pin0. In this interrupt subroutine, the PIC will send some data to USART to communicate with the other PIC.
    Also, I need another interrupt which is Rx of the USART. When the PIC 1 sends some data to the PIC 2, it is supposed to get back some data from the Rx.
    I get stuck of how to use interrupt in this.
    By the way, what function do you use to get out of the interupt subroutine when it is done. And how to set up priority interrupt; for example external PORTB pin0 interrupt is priority #2 and Rx of USART is priority #2.
    Thank you
    cubi
     
Loading...