Multi-Threading


Closed Thread
Results 1 to 23 of 23

Thread: Multi-Threading

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And what's wrong with the examples in the instant interrupt threads?
    I'd like to know that too.
    <br>
    DT

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Ok...

    So we have one led you want to flash in a fading way.

    How frequently do you want to flash it?

    Do you want to do other stuff while flashing the LED? In that case what will the PIC do?

    Can you put the LED on PORTB.3?

    How fast do you want to fade it up and down?

    How smooth do you need it, how many steps would you like the led to have on the way up and down?


    Before we even try to untangle the code for this it would be nice to know that you can use this pin and get the other information as well.

    /me

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jumper View Post
    Can you put the LED on PORTB.3?
    I'd doubt it...
    http://www.picbasic.co.uk/forum/showthread.php?t=9275
    Check post #32 and #33!

  4. #4
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    Jumper if you want to design a code example do not stick to values, stick to variables instead. Frequency should be f. Other concurrent thread(s) exist while fading in/out. There is no data available about them yet. Just use "LED", I'll use a pointer to the right port like LED VAR PORTX.Y. Speed of fading should be a function of frequency. Freqency means: every 1/f seconds there is a change. If LED is off, Led_fade_routine starts and vv. Led_fade_routine consists of fade_in_time = 2/f and fade_out_time = 2/f. Smoothness depends on OSC. Should be as smooth as possible, ie chunks_duration should be at a minimum.

    Thanks for your initiative. I appreciate that.
    Last edited by Ted's; - 27th August 2008 at 23:25.

  5. #5
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Doh?

    Did I miss something? In my code example I have LED as an alias for a port and I can't see I use any other values than T1CON (which is a register).

    If you are referring to my question about moving the LED to PORTB.3 it is only because I wanted to know if it was possible, and in that case we could use the HPWM for the fading. Doing that way would take very little instruction time and still give a nice fading effect since we only need to change the dutycycle once in a while to get a very smooth fading effect.

    I am deeply sorry that my poorly written code example upset you.

    over and out

    /me

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Ted stop winding people up that are trying to help you. Folks give up their time for free around here. If you don't like an answer then be polite, say "Thank You" to acknowledge the time they may have devoted to potentially a lost cause, and move on.

    In case you're not aware... the short answer to your question at Post #1 is Yes.

    If yor PIC has ADC, Comparators, CCPM, USART etc the you can SIMULTANEOUSLY perform any or all of those functions whilst doing something else altogether AT THE SAME INSTANT IN TIME. Go do a forum SEARCH, this has been discussed before.

    Alternatively you can TIME-SLICE your code... in the simplest form, using your flashing LED for example, say the LED is flashing at a 2Hz rate, you can switch ON your LED, then go do something else for 250mS before you need to devote an instruction to switching it OFF Gee... at 4MHz, that's a shed load of instructions you can carry out whilst that LED is ON, and again when it's OFF. To the casual observer, it will appear as if the PIC is doing multiple tasks.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    How would you use the ADCIN command to read the value of a pot while simultaneously doing something else?

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Setup a hardware peripheral like capture, hardware PWM, counter, UART, etc and enable
    it. They will all run simultaneously in the background while you're sampling the A/D input.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Multi Slow speed PWM and Instant Interrupts
    By DaveC3 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2010, 12:50
  2. multi functions button press
    By malwww in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th May 2009, 00:12
  3. 16-48 pin Multi slow PWM
    By krohtech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th March 2009, 03:28
  4. Multi diomencinal array
    By morphyn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th February 2009, 21:19
  5. parallel port multi pic programmer?
    By SuB-ZeRo in forum Schematics
    Replies: 8
    Last Post: - 25th June 2005, 10:20

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