Serin and TMR0


Closed Thread
Results 1 to 7 of 7

Thread: Serin and TMR0

  1. #1
    capitano's Avatar
    capitano Guest

    Post Serin and TMR0

    It's possible use Serin command and TMR0 interrupt in the same program ?

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


    Did you find this post helpful? Yes | No

    Default

    why not??? the only thing you have to care about IMO, is to disable interupts before using SERIN.
    Steve

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

  3. #3
    capitano's Avatar
    capitano Guest


    Did you find this post helpful? Yes | No

    Post Serin and TMR0

    My program must turn on 64 led connected to PIC with 4 mux 74HC154

    This is my program but it don't work fine, i try to disable interrupt but ...



    DEFINE OSC 4 'Definisco fre. osc. quarzo

    ' *****************************
    ' LIBRERIE

    Include "modedefs.bas"

    ' ************************************
    ' IMPOSTA PORTE

    TRISA = 0 ' Imposto la porta A come uscita
    TRISB =%10000000 ' Imposto la porta B come uscita
    OPTION_REG=%11010001

    PIE1=%00000000
    ADCON1=%00000111

    ' ************************************
    'VARIABILI

    TX var PORTB.6
    RX var PORTB.7
    Mode var PORTB.5

    EN1 VAR PORTA.0
    EN2 VAR PORTA.1
    EN3 VAR PORTA.2
    EN4 VAR PORTA.3

    x var byte ' Definizione variabile tipo byte
    k var byte
    j var byte
    led1 var byte
    led2 var byte
    stato var bit[64]
    pos var byte



    high EN1
    high EN2
    high EN3
    high EN4

    for k=0 to 63
    stato[k]=0
    next k


    INTCON = %11100000

    ON INTERRUPT GoTo interr



    ' **************************************
    'PROGRAMMA PRINCIPALE



    mainloop: 'label



    intcon.5=0

    SERIN RX,T9600,pos

    intcon.5=1

    stato[pos]=1 -----------------> Active led a position pos



    GoTo mainloop ' ritorna allla label iniziale






    '***********************
    'GESTIONE DI INTERRUPT

    Disable

    interr:


    '*********************
    'Interrupt TMR0 -------------->>>' Routine to scan all 64 led
    I can't interrupt it

    If INTCON.2=1 then


    for x=0 to 15

    if stato[x]=1 then

    portb.0=x.0[3]
    portb.1=x.0[2]
    portb.2=x.0[1]
    portb.3=x.0[0]


    low EN1
    high EN2
    high EN3
    high EN4

    pause 1
    endif

    next x


    high EN1
    high EN2
    high EN3
    high EN4


    for x=0 to 15

    j=x+16

    if stato[j]=1 then

    portb.0=x.0[3]
    portb.1=x.0[2]
    portb.2=x.0[1]
    portb.3=x.0[0]


    high EN1
    low EN2
    high EN3
    high EN4

    pause 1
    endif

    next x



    high EN1
    high EN2
    high EN3
    high EN4

    for x=0 to 15

    j=x+32

    if stato[j]=1 then

    portb.0=x.0[3]
    portb.1=x.0[2]
    portb.2=x.0[1]
    portb.3=x.0[0]


    high EN1
    high EN2
    low EN3
    high EN4

    pause 1
    endif

    next x

    high EN1
    high EN2
    high EN3
    high EN4

    for x=0 to 15

    j=x+48

    if stato[j]=1 then

    portb.0=x.0[3]
    portb.1=x.0[2]
    portb.2=x.0[1]
    portb.3=x.0[0]


    high EN1
    high EN2
    high EN3
    low EN4

    pause 1
    endif

    next x

    high EN1
    high EN2
    high EN3
    high EN4


    INTCON.2=0
    endif



    Resume
    Enable






    thank you in advance for your availability and excuse me for my english

    Christian

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Christian,

    what does your schematic look like?

    regards

    Ralph

  5. #5
    Join Date
    Aug 2005
    Location
    Weifang, Shandong, CHINA
    Posts
    1


    Did you find this post helpful? Yes | No

    Exclamation Interrupt with serin command

    I am using a PIC16F88 with external resonator of 4Mhz.

    4 leds connected to portb pins and they are flashing in random in time with the internal timer1 and interrupt.

    I have a 433mhz transmitter on another device sending :
    serout rfmod,baud,[qual, dataout] ' qual = 10 and dataout = 11

    I am not sure how to set the serin command on portb.3 to look for an interrupt of receiving this serial data, once received it should turn of a select led on the portb pin.

    Any ideas ? or help appreciated please.

    Thanks

  6. #6
    yaskolo's Avatar
    yaskolo Guest


    Did you find this post helpful? Yes | No

    Default Timer0,pasue,serin :(

    i am using tmr0 interrupt in picbasic.
    when i use pause,pulsin or serin command interrupt is not work correctly. can you help me for this. how can i use interrupt correctly with serin and pause.
    or if i use asm interrupt code is it work ?.

    thanks

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


    Did you find this post helpful? Yes | No

    Default

    Those statement you said must be terminated prior to jump to interrupt routines. Using loop of short PauseUs, Using internal USART, create your own PULSIN statement will help.

    Now it depend of your skill level. Usually i don't use PULSEIN, but i use an internal TIMER in counter mode (something like RA4 T0CKIN) with a PAUSE (or pause loop). Same for Usart. Sure that's a bit harder but save a huge amount of codespace. Maybe, i said maybe, Darrel's instant interupt may be of help but i'd never test them.

    Even in assembler, SERIN, PAUSE, PULSEIN, should be terminated prior to jump to an interrupt handler. IMHO so far...
    Steve

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

Similar Threads

  1. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02

Members who have read this thread : 1

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