Processing 2 different parts with 16F872 ?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44

    Default Processing 2 different parts with 16F872 ?

    Hi there,
    I´m a beginner in PicBasic and i want write my first program. It was really hard enough for me to change the configuration bits of this PIC cause of WDT problems.
    Now my question is very simple.
    Is it possible, that the PIC is running two different processes at the same time?
    e.g. the 1st process only works once, when power up my board
    and the second part is searching for a pressed button (matrix)
    How can i solve this problem that both parts work simultanously?
    Maybe someone can help me?
    I´m using MicroCode Studio v3.0.0.0, Pic Basic Pro Compiler v2.47 & MPLAB IDE V7.60
    I hope that my english isn´t too bad and you can understand me...

    '****************************************
    '* Name : Matrix.BAS *
    '* Author : Robson *
    '* Notice : *
    '* : All Rights Reserved *
    '* Date : 20.06.2007 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '****************************************
    ' first process starts here
    ' this routine should run once by power up the PIC

    for x = 1 to 5 ' Wait 10 Seconds
    pause 2000
    next x
    PORTB.1 = 0

    for x = 1 to 3 ' Wait 6 Seconds
    pause 2000
    next x
    PORTB.1 = 1

    for x = 1 to 2 ' Wait 4 Seconds
    pause 2000
    next x
    PORTB.1 = 0
    ' this was the 1st part which only runs on startup
    ' for this time (20 seconds) the input on the matrix don´t work
    goto main

    ' here starts the second Part which should run simultanously
    ' while the first part is running
    main:
    col1 = 1
    col2 = 0
    col3 = 0
    savepos = pos

    if row1 = 1 then
    pos = 4
    endif
    if row2 = 1 then
    pos = 3
    endif
    if row3 = 1 then
    pos = 2
    if savepos = 0 then goto main
    endif
    goto col2check
    ' etc .......
    goto main
    end
    Last edited by Robson; - 21st June 2007 at 01:44.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,127


    Did you find this post helpful? Yes | No

    Default

    What you are looking for is a kind of multi-tasking. The solution for this are interrupts and the best resource is Darrel Taylor, http://www.pbpgroup.com/modules/wfse...php?category=4

    His is the author of Instant Interrupts. Study the examples and you will have the effect you want.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Well, Thank you Ioannis!

    And, for the keypad part, here's mister_e's keypad routine's being used with Instant Interrupts.
    http://www.picbasic.co.uk/forum/showthread.php?p=37196

    Should put you on the Fast Track.
    <br>
    DT

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,127


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Well, Thank you Ioannis!

    And, for the keypad part, here's mister_e's keypad routine's being used with Instant Interrupts.
    http://www.picbasic.co.uk/forum/showthread.php?p=37196

    Should put you on the Fast Track.
    <br>
    You are welcome! But, don't you ever sleep? Here is 11 in the morning!

    I suppose you are at west coast?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Party all night, sleep all day.

    It's just that the Party's on my computer.
    So nobody else wants to come over.
    <br>
    DT

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,127


    Did you find this post helpful? Yes | No

    Default

    Beers on me!

    Unfortunately, we are too far away...!

    Ioannis

Similar Threads

  1. How to drive the Vinculum VDIP1 in UART mode
    By BrianT in forum Code Examples
    Replies: 41
    Last Post: - 23rd May 2013, 12:34
  2. Replies: 4
    Last Post: - 15th April 2009, 01:54
  3. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 22:40
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

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