DT_INT + 16F72 - what am I missing?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default DT_INT + 16F72 - what am I missing?

    Hi, I am trying to build a timer based application and using PIC16F72. My problem is that my PIC is not responding to the Serin data. I am using DT_INT to achieve the timing function.
    Please help me understand if I am missing something.
    My code goes like this:
    Code:
    ;
    ;-----------------PIC16F72---------------------------
    Include "modedefs.bas"
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    DEFINE OSC 4       ' OSCCON defaults to 4MHz on reset
     
    ;-------------CONFIGURATION FUSES SET HERE-------------------------
    @ __Config _XT_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _CP_ALL
     
    ;---------VARIABLES DECLARED HERE----------------
    PAUSE 100
    Rx Var PortB.7
    buz var PortA.2
    green var PortA.1
    red var PortA.0
    relay var PortC.2
    delay VAR word
    delayset var word
    get0 var byte
    o var bit
    s var bit
    get1 var byte
     
    ;------------REGISTERS SET HERE------------------------
      ADCON1=7
      PORTA=0
      PORTB=0
      PORTC=0
      TRISA = %000000
      TRISC = %00000000
      TRISB = %10000000
      OPTION_REG = %10000000  ' RAPU = off
      PORTA=0
      PORTC=0
      PORTB=0
     
    s=0
    high red : pause 500 : high relay : pause 500 : high green : pause 500 : high buz : pause 1000
    low red : pause 500 :low relay : pause 500 : low green : pause 500 : low buz : pause 1000
    ; the above works fine
    ;---------INTERRUPTS DECLARED HERE------------------------------
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    TMR1_INT,  _delaystop,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
     
    T1CON=$31
     
    ;-------------INTERRUPTS ENABLED HERE-----------------------------
    @   INT_ENABLE   TMR1_INT     ; Enable external (INT) interrupts
     ; the int works fine as I have toggled an led in ISR and it does toggle at regular intervals
    ;----------------MAIN PROGRAM STARTS HERE------------------------
    
    main:
     
    game:
     Serin PortB.7, N2400,["D33",get0]
    high buz : pause 50 : low buz : pause 500
     
       Select case get0
    ; all select case statements go here which switch on the relay part & leds as well
       End Select 
    goto main
     
    ;------------------[INTERRUPTS - interrupt handler]---------------------------------------------------
    delaystop:
    ; All code to switch off the relay goes here after certain time has elapsed
    @ INT_RETURN
    I dont know what I am missing but my PIC is not respnding to the serial data. The buzzer should beep once, but it doesn't. Am I missing something?
    I can upload the missing code if needed.

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


    Did you find this post helpful? Yes | No

    Default

    What is your hardware? I mean how is the controller connected to the PC?

    How are you sending the serial data stream?

    Ioannis

  3. #3
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    What is your hardware? I mean how is the controller connected to the PC?

    How are you sending the serial data stream?

    Ioannis
    I have an RF receiver attached to the unit. I even tried to remove the receiver and connect both PICs hard wired. Still no response.
    By the way, just to confirm that for the 16F72 do I need to connect 100nF anywhere else as well, I have one already connected to pin 19/20. Vss is supplied to pin 19 & 8, Vdd goes to pin20 only.

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


    Did you find this post helpful? Yes | No

    Default

    Have you tried disabling the Timer1 interrupt to see if it responds to serial data?
    Regards,

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

  5. #5
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Have you tried disabling the Timer1 interrupt to see if it responds to serial data?
    Yes I did, still no luck.

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


    Did you find this post helpful? Yes | No

    Default

    If you're using v2.6 you may want to switch to SERIN2 or DEBUGIN. SERIN has known timing issues: http://melabs.com/support/pbpissues.htm
    Regards,

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

  7. #7
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    I have got V2.5. Can I still try using DEBUG?

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


    Did you find this post helpful? Yes | No

    Default

    Yes. DEBUGIN should work fine. I would disable interrupts too. At least until you can get your serial input working.
    Regards,

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

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


    Did you find this post helpful? Yes | No

    Default

    > Serin PortB.7, N2400,["D33",get0]

    With that statement, get0 is a qualifier.
    I think you wanted that to be the variable that receives the data.
    So it should be outside of the square brackets.

    Serin PortB.7, N2400,["D33"],get0
    DT

  10. #10
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    > Serin PortB.7, N2400,["D33",get0]

    With that statement, get0 is a qualifier.
    I think you wanted that to be the variable that receives the data.
    So it should be outside of the square brackets.

    Serin PortB.7, N2400,["D33"],get0
    Thanks to all. The problem is now sorted.

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