PDA

View Full Version : DT_INT + 16F72 - what am I missing?



Megahertz
- 25th June 2010, 14:35
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:

;
;-----------------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.

Ioannis
- 25th June 2010, 15:46
What is your hardware? I mean how is the controller connected to the PC?

How are you sending the serial data stream?

Ioannis

Megahertz
- 25th June 2010, 15:57
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.

Bruce
- 25th June 2010, 16:07
Have you tried disabling the Timer1 interrupt to see if it responds to serial data?

Megahertz
- 25th June 2010, 16:07
Have you tried disabling the Timer1 interrupt to see if it responds to serial data?

Yes I did, still no luck.

Bruce
- 25th June 2010, 16:16
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

Megahertz
- 25th June 2010, 16:29
I have got V2.5. Can I still try using DEBUG?

Bruce
- 25th June 2010, 16:32
Yes. DEBUGIN should work fine. I would disable interrupts too. At least until you can get your serial input working.

Darrel Taylor
- 25th June 2010, 18:03
> 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

Megahertz
- 25th June 2010, 18:42
> 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.