Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 18th May 2008, 12:32 PM   (permalink)
Default

I'm using MPLAB V8.02, I just pick the value from the drop down box.

Mike.
Attached Images
File Type: png Stimulus.png (21.8 KB, 7 views)

Last edited by Pommie; 6th July 2008 at 04:12 PM.
Pommie is offline  
Reply With Quote
Old 18th May 2008, 12:34 PM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
I'm using MPLAB V8.02, I just pick the value from the drop down box.

Mike.
hi,
I have just downloaded from microchip MPLAB IDE V8.10, installing on my second PC, let you know.

EDIT:

Installed MPLAB IDE V8.10, I am now able to set up the Stimulus the same as you Mike. OK.

ie: restart at '0' etc.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 18th May 2008 at 12:40 PM.
ericgibbs is offline  
Reply With Quote
Old 18th May 2008, 12:39 PM   (permalink)
Default

Mine one does'nt have "0" so, I did something awkward, I have added 0 in time coloumn and for this 0 time I set RA2 to 1 and then I have 0 in the dropeout menu..........., oh god I can't go more easy than this in words ,Mike please tell me how did you attach the picture of stimulus window in your last post (I know how to attach a picture, but don't know how to copy an active window as a picture)
__________________
CHRIS
c36041254 is offline  
Reply With Quote
Old 18th May 2008, 01:15 PM   (permalink)
Default

Quote:
Originally Posted by c36041254 View Post
Mine one does'nt have "0" so, I did something awkward, I have added 0 in time coloumn and for this 0 time I set RA2 to 1 and then I have 0 in the dropeout menu..........., oh god I can't go more easy than this in words ,Mike please tell me how did you attach the picture of stimulus window in your last post (I know how to attach a picture, but don't know how to copy an active window as a picture)

hi,
Google for screenhunter its freeware.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Reply With Quote
Old 18th May 2008, 01:22 PM   (permalink)
Default

To copy the screen, press the key that has "Prt Scr/SysRq" (next to scroll lock) on it and the screen is copied to the clipboard. Go into your favourite graphics program and paste it.

Mike.
Pommie is offline  
Reply With Quote
Old 19th May 2008, 01:24 AM   (permalink)
Default

O.K. so this is what I have done to get "0" in restart, is it right to do so?
And the simulatio still does'nt work, after doing whatever in the thumbline I clicked apply then svaed the workbook, so this supposed to work.
Attached Images
File Type: png image1.png (15.6 KB, 2 views)
__________________
CHRIS

Last edited by c36041254; 19th May 2008 at 01:29 AM.
c36041254 is offline  
Reply With Quote
Old 19th May 2008, 02:03 AM   (permalink)
Thumbs up

Hey ! that works , 500 and 1500 were too long period ( though I should have some patient, sorry for that)I reduce them to 50 and 150.
Attached Images
File Type: png image 2.png (15.6 KB, 2 views)
__________________
CHRIS
c36041254 is offline  
Reply With Quote
Old 19th May 2008, 02:13 AM   (permalink)
Default

I guess you were using single step (F8). If you set a breakpoint as shown below, by double clicking in the grey border, then you can press f9 and the program will run until an interrupt occurs.

Mike.
Attached Images
File Type: png BreakPoint.png (16.6 KB, 2 views)

Last edited by Pommie; 6th July 2008 at 04:12 PM.
Pommie is offline  
Reply With Quote
Old 19th May 2008, 02:48 AM   (permalink)
Default

I know that but, pressing F9 with a break point runs progarmme only for first interrupt(as it should be) and then when I press agin F9 to cross over break point the whole MPLAB gets hang, only animation runs good but, that takes too much time.
__________________
CHRIS

Last edited by c36041254; 19th May 2008 at 02:53 AM.
c36041254 is offline  
Reply With Quote
Old 19th May 2008, 04:05 AM   (permalink)
Default

Quote:
Originally Posted by c36041254 View Post
I know that but, pressing F9 with a break point runs progarmme only for first interrupt(as it should be) and then when I press agin F9 to cross over break point the whole MPLAB gets hang, only animation runs good but, that takes too much time.
It shouldn't do that, it should stop at the breakpoint every time you press F9. It might be worth downloading and installing the latest version.

Does it now work on the hardware. A good way to generate interrupts is to turn on the WPUs (WPUA=2 and OPTION.7 = 0) and then just ground the pin. The debounce problem shouldn't matter, it will just jump a few counts.

Mike.
Pommie is offline  
Reply With Quote
Old 19th May 2008, 04:31 AM   (permalink)
Default

I haven't tried on the hardware because I was considering to make what Eric had suggested but, now it seems you have an easier idia but, I don't understand what do you mean by WPUs (WPUA=2 and OPTION.7 = 0)
__________________
CHRIS
c36041254 is offline  
Reply With Quote
Old 19th May 2008, 04:44 AM   (permalink)
Default

You can enable internal resistor on the pic chip, these are referred to as weak pullups (WPU). You turn them on by clearing bit 7 of the OPTION (0x81) register and setting the appropriate bit in the WPUA (0x95) register.

Mike.
Pommie is offline  
Reply With Quote
Old 19th May 2008, 05:11 AM   (permalink)
Exclamation

Well, I tried what you have suggested check the codes:

Code:
  		list	p=16f690 
		#include <p16f690.inc>
		__CONFIG -_MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
		ERRORLEVEL -302

	cblock	0x20
		temp	
		display	
		count	
	endc

;**************************STEUP THE CONSTANTS*******************************  

		org	0x00		;this is where we come on power up and reset
		goto	Main

;**************************INTRUPT ROUTINE************************************  

		org	0x04

		movwf	temp   		;this and the lable Loop will run simultenously
					;move w into f in case to there was someting in  
					;count(see first step of Loop) 

		incf	count,f  	;increase count by 1 and put result in count
		movlw	.10   		;load w with decimal 10
		subwf	count,w  	;subtract count from w and place result in w
		btfss	STATUS,C  	;if in above operation count<= w then carry bit 
					;is set, so check for that and skip next step 
					;if it is set 
		goto	carry_on
		goto	clear

carry_on:
		bcf	INTCON,0x01   	;clear the INTF, just in case(read tuto. 11)
		movfw	temp   		;move temp to w 
		retfie			;get out of intrupt loop (this will start over 
					; the whole INTRUPT LOOP again 
clear:
		clrf	count   	;set count to 0
		bcf	INTCON,0x01  	;clear INTF
		retfie
;*****************************MAIN PROGRAMME************************  
Main:

;*****************************SET UP THE INTRUP REGISTERS***********  

		bsf	INTCON,0x07  	; set globel intrupt (tell PIC that we will use intrupts)
		bsf	INTCON,0x04  	;
		bcf	INTCON,0x01

;******************************SET UP THE PORTS**********************  
		bsf	STATUS,RP0
		movlw	b'10000000'
		movwf	TRISC
		movlw	b'00000100'
		movwf	TRISA	;set RA2 as input (for interrupt)
		bcf 	STATUS,RP0
		bsf	STATUS,RP1
		bcf	OPTION_REG,0x07
		bsf	WPUA,0x02		             
                         clrf 	     ANSEL
	             bcf           STATUS,RP1
;******************************NOW SEND THE VALUE OF COUNT TO PORTC**  

Loop:
		movf	count,w
		movwf	PORTC
		goto	Loop
		END
but, that is also not working I think something wrong with hardware, any way I have a spare16f628 and will try some simpler code on that, there is just one problem with 16f628 and that is it does'nt have any ANSEL register so how can I set the PORTS to work for digital ckt?
__________________
CHRIS
c36041254 is offline  
Reply With Quote
Old 19th May 2008, 05:28 AM   (permalink)
Default

The 628 doesn't have an ADC module and so no ANSEL. It does have comparators and these have to be turned of by writing 0x07 to CMCON. You turn the WPUs on by just clearing bit 7 of the OPTION register and the int pin is RB0.

Mike.
Pommie is offline  
Reply With Quote
Old 19th May 2008, 05:45 AM   (permalink)
Exclamation

Here is the code for 628, pin 0 of port a will be HIGH and on interrupt pin 7 will also be high, running it in simmulation with F9 still hangs MPLAB and animation takes too much time, kindly check the code and tell me it is right or not then I'll move to hardware.

Code:
list p=16f628
		#include<p16f628.inc>
		__CONFIG  _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
		ERRORLEVEL   -302
		cblock	0x20
			temp       
  		endc
;******************************************************************
	org 0x00
	goto main
;***********************************INTERRUPT LOOP*****************
	org 0X04
inter:
	movlw b'10000000'
	movwf PORTA				;set pin 7 of port a HIGH
	goto	inter
main:
	bsf	INTCON,0x07
	bsf INTCON,0x03
	bcf	INTCON,0x00
;**********************************SET UP THE PORTS *****************
	bsf	STATUS,RP0			;switch to BANK 1
	movlw b'00000001'	
	movwf TRISB				;set RB0 as input
	movlw b'00000000'
	movwf TRISA                                               ;set PORT A all output
	bcf OPTION_REG,0x07			
	bcf STATUS,RP0			;back to BANK 0
	movlw 0x07
	movwf CMCON				

Loop:
	movlw b'00000001'		
	movwf PORTA				;set pin 0 of port a HIGH
	goto Loop
	END
thanks a lot for all help!
Attached Images
File Type: png image 3.png (15.9 KB, 1 views)
__________________
CHRIS

Last edited by c36041254; 19th May 2008 at 05:55 AM.
c36041254 is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
PIC16F628a Problem generating a RCIE interrupt Norlin Micro Controllers 3 16th January 2008 01:43 AM
Priority Interrupt Controller Stellarcore Datasheet/Parts Requests 14 13th September 2007 04:13 PM
Help with timer and interrupt please.. AntRoFiZ Micro Controllers 2 29th May 2007 11:48 AM
Question about Interrupt tinhnho Micro Controllers 3 11th February 2007 07:07 PM
Interrupt on GP Change problem Dan East Micro Controllers 2 22nd May 2004 05:12 PM



All times are GMT. The time now is 06:34 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.