how to generate two signals from two ports at the same time by using p16f84


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    yes i have an advisor teacher but he does not say anything about how i can do it. i guess he just wonder how i find a solution for this project.

    i have started usual basic loop without using tmr0, and for a signal it works well but generating second one with different frequencies causes timing problem. i also tried to implement assembler codes in order to have more time space however it did not help me.

    at least i want to find a method so as to generate these signals having pulse witdh x8 ( 8,16,..320 mic. sec ). in this program i am trying to use basic timing by using tmr0 and interrupt. i guess i need a 8 micro seconds time period which constant?

    thanks a lot


    define OSC 10
    timer0 var word
    timer1 var word

    A0 VAR PORTA.0
    A1 VAR PORTA.1


    on interrupt goto int_timer

    OPTION_REG=%00000000
    TMR0=255
    INTCON=%10100000

    TRISA=0
    LOW PORTA

    timer1=0
    timer0=0


    enable
    main:

    goto main

    disable
    int_timer:

    timer0=timer0+1
    if timer0=>3 then ' 3 is a random number
    timer0=0
    toggle a0
    else
    endif

    timer1=timer1+1
    if timer1=>10 then ' 10 is a random number
    timer1=0
    toggle a1
    else
    endif


    INTCON.2=0
    TMR0 = 255
    resume

    end

  2. #2
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    i have tried to obtain accurate time by changing tmr0 and prescaler, but still no answer

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


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    You have a lot of stuff in the ISR. Take the IF_THEN_ELSE out of the ISR.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    yes, i have tried it also, i put them in main loop but i could not obtain time accuracy.

  5. #5
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    i need a loop with constant 8 mic. sec. time period and multiplying it with two different variables to obtain to different signal. but how?

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


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    How fast are you allowed to run the MCU?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    i am allowed to use pic16f84 and 10 mhz crystal. i think this project is impossible, since i have struggled so much, but unfortunately he has a circuit doing that with pic16f84 :0

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts