Scoobystu said:Thanks for pointing that out Phalanx. I will be using the comparator at a later date but I want to crawl before I can walk.
I take it the comparator is switched off and on in the config line, or do I do it via CMCON0?
Scoobystu said:OK I changed the code to read Count1 equ 20h and Count2 equ 21h but it still doesn't work. Is the comparator a red herring or do I need to sort it out first?
I take it that I really need to set up the CMCON0 register as described in page 33 of the data sheet? Otherwise I will encounter problems?
The other area I noticed was that to switch the comparator off Bits 2 - 0 in CMCON0 should be '111' as described on page 49. CM<2:0>=111.
I suppose that would make sense as the
MOVLW 07h
MOVWF CMCON0
would do that for you!?
Should I just put the whole piece of code into my program? Will this make my DECFSZ instruction work?
decfsz COUNT2, 1
decfsz COUNT2, F
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
retlw 0x00
Scoobystu said:What does the '$' symbol do?
I think I can see light at the end of the tunnel.....
PS How can I post my full code up here for scrutiny?
am trying to develop some code to create a timer that will switch on a transistor.
I followed the Tutorial in the MPLAB users guide and it worked out as described. When I tried to do the same for a PIC12F683 I got to the point where I had used the project wizard to select the template files and the linker files. When I tried to Build the project I got the following error message.
"MPLINK 3.94, Linker
Copyright (c) 2005 Microchip Technology Inc.
Error - section 'INT_VECTOR' can not fit the absolute section. Section 'INT_VECTOR' start=0x00000004, length=0x00000010
Errors : 1
BUILD FAILED: Mon Jul 31 10:26:34 2006"
As I am completely new to this I need some advice on how to get the linker files to work with my chosen 12F683 chip.
Thanks
Stuart
Resolution: Hello Stuart,
If you edit the linker file such that the Vectors section ends at 0x1F and the start of Page is at 0x20 your code should build without any additional errors. See below,
CODEPAGE NAME=vectors START=0x0 END=0x1F PROTECTED
CODEPAGE NAME=page START=0x20 END=0x7FF
Regards.
list p=12F683, b=8, c= 102, n=71, t=on, st=off, f=inhx32
;******************************************************************
;* *
;* Filename: 12F683 Example.asm *
;* Author: Mike McLaren, K8LH (k8lh@arrl.net) *
;* Date: 31-Aug-06 (revised 31-Aug-06) *
;* *
;* PWM Example *
;* *
;* - Uses 12F683 INTOSC (8-MHz) *
;* *
;* MPLab: 7.40 (tabs=8) *
;* MPAsm: 5.03 *
;* *
;******************************************************************
#include <p12f683.inc>
errorlevel -302 ; disable bank warning messages
__config _FCMEN_OFF&_IESO_OFF&_MCLRE_OFF&_WDT_OFF&_INTOSCIO
;
; _FCMEN_OFF ;
; _IESO_OFF ;
; _BOD_ON ; default
; _CPD_OFF ; default
; _CP_OFF ; default
; _MCLRE_OFF ; use MCLR pin as an input
; _PWRTE_OFF ; default
; _WDT_OFF ;
; _INTOSCIO ;
;
Temp equ 0x20 ; absolute variable assignment
;******************************************************************
;* *
;* *
;* *
;* *
;* *
;******************************************************************
org 0x0000
Vect_Reset
clrf STATUS ; force bank 0 |B0
;
; initialize peripherals and port I/O
;
movlw b'00000111' ; |B0
movwf CMCON0 ; turn comparator off |B0
clrf GPIO ; clear GPIO output latches |B0
bsf STATUS,RP0 ; bank 1 |B1
clrf ANSEL ; turn off analog pin functions |B1
clrf TRISIO ; set all pins as outputs |B1
;
; setup INTOSC for 8-MHz operation
;
movlw b'01110001' ; |B1
movwf OSCCON ; 8-mhz INTOSC system clock |B1
Stable btfss OSCCON,HTS ; oscillator stable? |B1
goto Stable ; no, branch, else |B1
bcf STATUS,RP0 ; bank 0 |B0
;
; configure PWM for 20-KHz and 50% duty cycle
;
movlw b'00000000' ; '000000001' |B0
; 0------- unused
; -0000--- postscaler 1:1
; -----0-- TMR2 off
; ------00 prescaler 1:1
movwf T2CON ; 0.5-usec ticks (8-MHz clock) |B0
bsf STATUS,RP0 ; bank 1 |B1
movlw d'100'-1 ; 100 * 0.5-usec ticks |B1
movwf PR2 ; 50.0-usec period (20-KHz) |B1
bcf STATUS,RP0 ; bank 0 |B0
movlw d'50' ; |B0
movwf CCPR1L ; set PWM duty cycle 50% |B0
movlw b'00001100' ; '00001100' |B0
; 00------ unused
; --00---- DC1B1:DC1B0
; ----1100 PWM mode
movwf CCP1CON ; turn on PWM mode |B0
clrf TMR2 ; |B0
bsf T2CON,TMR2ON ; start TMR2 |B0
;
Loop goto Loop ; loop indefinately |B0
;
end
That may have been a viable recommendation in the dark ages, but there are far more advantages to using MPLAB now days than there are disadvantages.Nigel Goodwin said:You might do what I do?, use MPASMWIN and not MPLAB, no linker files, and no messing about!.
Originally Posted by Nigel Goodwin
You might do what I do?, use MPASMWIN and not MPLAB, no linker files, and no messing about!.
Scoobystu said:So, Nigel, I could use MPASMWIN. I never looked at that, Is it the predecessor to MPLABS?
Scoobystu said:The one feature I liked about MPLABS is that it has a simulator that would show you your program working step by step. Although it doesn't show me what I want to see so it is pretty pointless really.
I take it MPASMWIN would tell you if your code did not build before you downloaded it to the PIC.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?