Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help for Assembler 12F675

Status
Not open for further replies.

MAS4585

Newbie level 5
Newbie level 5
Joined
Nov 27, 2016
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
57
Hello All

Good Evening...

I am trying to design a Fish feeder timer with 12F675. Its has 5 Pre Programmed out put that are for 1 Second,2 ,4,6 and 8 seconds.
Output will turn off after the pre programed time was reached. Simulation of the circuit with Proteus is working... But the real hardware showing some faulty trigger.

when I complile the code with MPlab 8.33, There show an error.

"Symbol not previously defined (TMR0IE)"


Please see the complete code below.

Code:
 list n=0, c=150, r=dec		
; File: main.asm		
; Target: PIC12F675		
;*********************************************************************		
;                          ___ ___		
;                   VDD ->|1  U  8|<- VSS		
;                  LED1 <>|2     7|<> LED3		
;                  LED2 <>|3     6|<> LED4		
;                  SW1n ->|4     5|<> LED5		
;                          ¯¯¯¯¯¯¯		
;                         PIC12F675		
;		
;*********************************************************************		
;		
;  If the switch is Press and hold (My timer output is enable for 1 Minute minimum) either Press, all LED will be ON.		
;  After 1 Second, LED 1 Turn Off,		
;  After 2 Second, LED 2 Turn Off		
;  After 4 Second, LED 3 Turn Off		
;  After 6 Second, LED 4 Turn Off		
;  After 8 Second, LED 5 Turn Off.		
;		
;  (5 LED is used for Manual Timer selection for the Motor will Enable..)		
;		
#include <p12f675.inc>		
	LIST		
		
;==========================================================================		
;  MPASM PIC12F675 processor include		
;		
;  (c) Copyright 1999-2013 Microchip Technology, All rights reserved		
;==========================================================================		
	LIST
	errorlevel -302         ; suppress banksel warning	messages		
				
	__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON	&	_MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF		
				
#define TIMER0_INTERRUPTS_PER_SECOND D'4000'				
#define LED1 GPIO,5				
#define LED2 GPIO,4				
#define LED3 GPIO,0				
#define LED4 GPIO,2				
#define LED5 GPIO,1				
#define SW1n GPIO,3				
				
				
ISR_DATA    udata_shr  0x20
WREG_save       res 1
STATUS_save     res 1

TIMER_DATA  udata_shr
IntsInOneSecond res 2
Seconds         res 1

RESET_CODE  CODE 0x000
	goto    Start
ISR_CODE    CODE 0x004
	movwf   WREG_save
	movf    STATUS,W
	movwf   STATUS_save

	btfsc   INTCON,TMR0IE
	btfss   INTCON,TMR0IF
	goto    ISR_Exit
	bcf     INTCON,TMR0IF
	movlw   256-250+3
	addwf   TMR0,F
	movlw   -1
	addwf   IntsInOneSecond,F
	skpc
	addwf   IntsInOneSecond+1,F
	skpnc
	goto    ISR_Exit
	movlw   HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
	movwf   IntsInOneSecond+1
	movlw   LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
	movwf   IntsInOneSecond
	incf    Seconds,F

ISR_Exit:		
	movf    STATUS_save,W		
	movwf   STATUS		
	swapf   WREG_save,F		
	swapf   WREG_save,W		
	retfie

START_CODE  CODE			
Start:			
	btfsc   STATUS,RP0			
	goto    OscillatorCalibrationFailed			
	banksel OSCCAL			
	call    GetOSCCAL			
	movwf   OSCCAL			
OscillatorCalibrationFailed:			
	banksel ANSEL			
	clrf    ANSEL			
	clrf    TRISIO			
	movlw   B'11011111'			
	movwf   OPTION_REG			
	banksel INTCON			
	clrf    INTCON			
	clrf    GPIO			
	movlw   0x07			
	movwf   CMCON			
	movlw   HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)			
	movwf   IntsInOneSecond+1			
	movlw   LOW(TIMER0_INTERRUPTS_PER_SECOND-1)			
	movwf   IntsInOneSecond			
	clrf    Seconds			
	clrf    TMR0			
	movlw   256-250+3			
	addwf   TMR0,F			
	bsf     INTCON,TMR0IE			
	bsf     INTCON,GIE

			
			
			
AppStart:			
	clrf    GPIO			
AppLoop:			
	btfsc   SW1n			
	goto    AppLoop			
	bcf     INTCON,TMR0IE			
	movlw   HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)			
	movwf   IntsInOneSecond+1			
	movlw   LOW(TIMER0_INTERRUPTS_PER_SECOND-1)			
	movwf   IntsInOneSecond			
	clrf    Seconds			
	movlw   B'00110111' ; LED1-5 on			
	movwf   GPIO			
	bsf     INTCON,TMR0IE			
AppTimeout:			
	movf    Seconds,W			
	xorlw   D'1'			
	skpnz			
	goto    LED1_off			
	xorlw   D'1'^D'2'			
	skpnz			
	goto    LED2_off			
	xorlw   D'2'^D'4'			
	skpnz			
	goto    LED3_off			
	xorlw   D'4'^D'6'			
	skpnz			
	goto    LED4_off			
	xorlw   D'6'^D'8'			
	skpnz			
	goto    LED5_off			
	xorlw   D'8'			
	sublw   D'8'			
	skpc			
	goto    WaitForButtonUp			
CheckSwitch:			
	btfsc   SW1n			
	goto    AppStart			
	goto    AppTimeout
;
;
;
WaitForButtonUp:				
	btfsc   SW1n				
	goto    AppStart				
	goto    WaitForButtonUp
;
;
;
LED1_off:				
	movlw   B'00010111' ; LED1   off				
	movwf   GPIO				
	goto    CheckSwitch				
LED2_off:				
	movlw   B'00000111' ; LED1-2 off				
	movwf   GPIO				
	goto    CheckSwitch				
LED3_off:				
	movlw   B'00000110' ; LED1-3 off				
	movwf   GPIO				
	goto    CheckSwitch				
LED4_off:				
	movlw   B'00000010' ; LED1-4 off				
	movwf   GPIO				
	goto    CheckSwitch				
LED5_off:				
	movlw   B'00000000' ; LED1-5 off				
	movwf   GPIO				
	goto    CheckSwitch	

OSCCAL_CODE CODE 0x3ff
GetOSCCAL:
	end

I dont understand, What is real problem....Any help would appriciated.

Regards
 
Last edited by a moderator:

Try using "T0IE" instead, that is the name used on the data sheet.

Brian.

Yes...Its working....and compiling done with 0 % error.

But the simulation, in proteus, There is a warning message...

"Effect of writing OSCCAL register not modelled"....

How is it possible?

Regards...
 

I have just checked the include file P12F675.INC and TMR0IE is correct, you could just use the value 5 instead. The normal mistake that everyone makes is to use a o instead of an 0 in the name.
 

Sounds self-explanatory to me. It's Proteus.

Hi Fvm..

Greetings...

How to overcome the message "Effect of writing OSCCAL register not modelled" ?

and the circuit tested in real hardware, There is some unwanted triggering occured ...... sometimes its working good... but aftersome time all LEDs are blinking...

why this happen?

Regards

- - - Updated - - -

this is the video for the real hardware work...

https://youtu.be/kuD_LctpKAo
 

The message is just a warning about the simulation, it doesn't mean there is a problem with the code.
The OSCCAL register applies a small offset to the internal oscillator calibration but the exact amount it shift the frequency is not well defined. The main calibration is done in the factory with the OSCCAL being left to the user for 'fine tuning' if needed. Obviously a simulation can't tell how much adjustment, if any is needed.

Something else is causing your unwanted triggering, my first suspicion would be interference from the motor. Do you have good decoupling on the PIC supply pins and sufficient current isolation between the motor supply and PIC supply?

Brian.
 
The message is just a warning about the simulation, it doesn't mean there is a problem with the code.
The OSCCAL register applies a small offset to the internal oscillator calibration but the exact amount it shift the frequency is not well defined. The main calibration is done in the factory with the OSCCAL being left to the user for 'fine tuning' if needed. Obviously a simulation can't tell how much adjustment, if any is needed.

Something else is causing your unwanted triggering, my first suspicion would be interference from the motor. Do you have good decoupling on the PIC supply pins and sufficient current isolation between the motor supply and PIC supply?

Brian.


Its just my Idea only and not the motor to connect the circuit. I use LED in the output for testing the output.

Now OSCCAL register problem cleared. Think the circuit work well now in another PCB. 1K resistor are used in series with the output of the 12F675.

Updated circuit are here

1.jpg


How can use a potentiometer insted of various LED for time setting....?

Regards
 
Last edited by a moderator:

That PIC has a built-in ADC so if you can spare the input pin, wire the potentiometer across VSS and VDD with the wiper going to the ADC input. Then use the ADC module to read the voltage (the ADC register value will suffice, there is no need to convert it to Volts) and use that value to pre-load the timer.

As you change the potentiometer setting you make the timer delay change.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top