![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
I'm using MPLAB V8.02, I just pick the value from the drop down box.
Mike. Last edited by Pommie; 6th July 2008 at 04:12 PM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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. |
||
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) | |
|
Quote:
hi, Google for screenhunter its freeware.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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.
__________________
CHRIS Last edited by c36041254; 19th May 2008 at 01:29 AM. |
|
|
|
|
|
|
(permalink) |
|
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.
__________________
CHRIS |
|
|
|
|
|
|
(permalink) |
|
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. Last edited by Pommie; 6th July 2008 at 04:12 PM. |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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. |
||
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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
__________________
CHRIS |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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
__________________
CHRIS Last edited by c36041254; 19th May 2008 at 05:55 AM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| 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 |