Wind measuring m/s with PIC16F628, in assembler

Status
Not open for further replies.

Windmiller

Member level 4
Joined
Mar 30, 2010
Messages
76
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Sweden
Activity points
1,997
Hi!

I'm going to (try to) make a handheld wind measuring device in m/s unit integers only. Will code this in assembler.

I have the routine to convert hex to decimal so that I can display 0-99 on two 7-segment LCDs.

What I was thinking:
Using a PIC16F628 with the internal clock, and two 7-segment LCD dispalys.
Add an interrupt on one pin that will get external signal from a propeller rpm source switch, that only will increase a counter every time the switch is beeing switched (light switch).

Create a timer fast enough to display numbers >= 10 on the first LCD and then the <= 9 on the second, don't know what speed 8ms?? Add one counter in the timer loop that will call a new function every 1000ms / 1sec.

The 1sek function will measure the m/s by the knowledge of the 1 secound run and the number from the input switch counter, somehow. And reset the inerrupt counter for the next secound calculation.

But I don't know if this is the best way, or is there a better way of doing this?
If it is a good way, what values do I need to set the timer (16 bit TMR1L, TMR1H) and the prescaler to get my 8ms for the displays * 125 = 1000ms for the calculation function.

Someone who can help me, has been there already or just know how to do this? :?

I'm not asking for a complete solution, just hints on the way
Thanks in advice..

/ Morgan
 
Last edited:

OK, here are some hints, I have not actually built an anemometer but I have encountered similar situations:

You are looking to convert the interval between signals from the propeller into a meaningful number. Basically, that's a frequency counter with a conversion carried out on the result so pulses per time interval is converted to m/s. I'm assuming you can detect a fixed number of pulses per rotation.

You can count either frequency or period with a timer. Frequency is measured as the number of counts within a fixed period. Period is the number of fixed cycles between pulses.
For period, you could set TMR1 to count internal clock cycles, then at each pulse, read the timer value and reset it to zero. So for each pulse you get a number from the timer. Faster pulses will result in shorter periods and smaller values.
For frequency, again set TMR1 to count internal clock cycles but this time use it to define a set interval, you can do this by pre-loading the counter and waiting for it to roll over to zero, either polling it or detecting by interrupt. During the interval, look for and count any pulses from the propeller. This method measures pulses per interval so the number is higher if the propeller rotates faster.

There isn't a best way to cater for all wind speeds, the frequency method is more accurate at high pulse rates and the period method is more accurate at low rates.

Brian.
 
Thank you Brian!

Now I know more, where and what to look for and I've started to laborate with some parts.
But I had a problem that I still have to pass, and it is that I must have the RA5/MCLR pin connected to positive current like the VDD pin.
Otherwise it will stop function, tested a timer with a blinking LED light flashing on and off every 500ms and it stops after about 10-15 blinks diffrent each time.
If I connect the MCLR to positive current like the VDD pin, it will continue with the flash.

I don't get this? Why it stops if MCLR is not connected..
 

Hi,

Pin4 , RA5 / Mclre is dual function, it is set by the Configuation Word to either a Digital Input function as Ra5 or the default option of Mclre / Reset pin.

When in the Mclre mode, the pin should be taken to Vdd by a 10k resistor to allow the Pic program to run normally, if taken low by a Reset switch then the pic program is reset.

If the pin is left floating when set as Mclre then anything can happen as you describe.
 
Thank you very much wp100, how stupid of me.. It all make sence to me now.
 

Well now I'm up and running!

I made a program in ASM that counts interrupts on the RB0/INT pin PIC16F628, with a TMR1 that reads the counter value from the intterupt every 4th secound. Used a LDR and a bright LED to measure RPM from a propeller, and it works! BUT, the LDR seems to be too slow for measuring high RPMs so it will skip some when it's counting.

Is it because the LDR is beeing too slow measuring higher RPMs??

Someone who got an idea? What can I use instead of the LDR that will be faster?

/ Morgan
 

I think long time back there was a wind speed meter project(jan 2003) in EPE magzine using pic. One can refer that for guidance and code.

Asimov
 

LDR response is always slow and in addition, it gives a voltage out which is proportional to the amount of light, what you want is an abrupt voltage change when the light is interrupted. I suggest using a photo-transistor or photo-diode instead of the LDR. A better alternative, if you can mechanically mount it is to use a slotted opto-coupler. This has the light source and sensor inside a single package with a slot between them. If you can arrange for your propeller or something attached to it to pass through the slot and interrupt the light beam it should work fast enough and in any ambient light conditions.

Brian.
 

Thank you Asimov!

I found it in their archive when I googled

/ Morgan

---------- Post added at 12:06 ---------- Previous post was at 12:04 ----------


Thank you for bringing knowledge to my door.
Ok, I see..

Now I got a TSOP1556 taken from the receiver and the IR-Led from the remote control for my X-BOX. Both at 56 kHz, tried to connect it instead of the LDR but it will not make the interrupt pin go high.

I have tried to connect the GND on the IR-transistor to GND, the Vs to DCV 5+ and the Out pin to the interrupt pin on the PIC16F628 with a pull-down resistor. Turned the IR-Led on but no interrupt!? I know someting's missing here.. but I really can't see what it should be.

Made more reading about the IR-transistor (because I know too little about them) and now I'm wondering..
The LDR is varying in the resistance so that the interrupt will go from low to high in voltage making the interrupt go off, and the IR-Transistor is varying in currency instead which also will result in a voltage change from low to high or vice versa ( U = I * R ). When I tried to measure the outcome voltage, it was constant whatever amount of light I applied or removed, i don't get how this photo transistor thing is working when it's not working like I thought it was. Is it a really small change in currency, so that I've missed it and overlooked it?

I will make some more measuring when I'm back home in the crypt.. after work..

/ Morgan
 
Last edited:

Your problem is caused by the TSOP1556. What you are trying to get is a logic level change as the light is interrupted, the TSOP doesn't do that. Inside the TSOP is a carrier filter so it rejects any signal that doesn't look like it comes from a real IR remote control unit. Basically, you don't get a steady light beam from a remote control, it sends a kind of Morse code pattern made by switching on and off very rapid bursts of light, usually around 38,000 per second. The IR receiver contains a filter that blocks anything that isn't at that frequency so it doesn't respond to room lights being switched on or even sunlight falling on it. Your LED is producing a steady light beam so the filter is rejecting it.
You have two options, you can pulse your LED at 38KHz so the TSOP accepts it, or you can change to a non-filtered IR receiver. Personally, I would go for the second option as it is simpler and will give more accurate results.

Brian.
 


Yes, you are right Brian!
I found the datasheet, actually this one's even at 56KHz.. my ***, better put it back in the X-Box remote.

Thank you very much.. I went for your second opinion and bought myself a non filtered foto-diode receiver instead, made some changes and now it is working like I want it to.

Now I'll get a suitable display for this.. and move on with the project.

/ Morgan
 

Ok, now I've been coding in assembler for a while, started with the PIC16F628 and made it work like expected. Now I'm trying to convert the code to PIC18F4550, but I have some problems with the look-up table in my code. It seems to jump to the interrupt address if W contains the value 3 or more when calling the LCD20 routine, but seems to work in the other LCDXX routines, I don't know if the code is faulty or if my programmer is messing it all up when writing it to the PIC. The programming utility doesn't seem to write the program to 100% but still no error report, I'm using a Velleman VM134 (serial) crap-programmer.

My code looks like this:

Code:
	errorlevel 	-302		; 

	ORG     	0x00
	GOTO		INIT

	ORG		0x04		; Interrupt vector
	NOP
	NOP
	CALL		IntRupt		; Interrupt routine
	BCF 		INTCON, 1	; Reset int flag
	RETFIE
	
INIT:	
Counter 	             EQU 0x20; Delay counter
SaveW		EQU 0x40	; To save W register
DHexVal		EQU 0x28	; Hex value to display
Tens		EQU 0x41	; Dec value to display LCD
Ones		EQU 0x42	; Dec value to display LCD
Disp10		EQU 0x30	; Displ 1:0
Disp11		EQU 0x31	; Displ 1:1
		        
	BANKSEL 	TRISA
  	MOVLW    	b'00000000'	; Set 0 to input
	MOVWF		TRISA
	BANKSEL 	0x5       	;
  	CLRF    	0x5		; Set All B pins to 0
	BANKSEL 	TRISB
        MOVLW    	b'00000001'	; Set 0 to input
	MOVWF		TRISB
	BANKSEL 	0x6       	;
  	CLRF    	0x6		; Set All B pins to 0
	BANKSEL 	TRISD
        MOVLW    	b'00000000'	; Set output
	MOVWF		TRISD
	BANKSEL 	PORTD       	;
  	CLRF    	PORTD		; Set All B pins to 0

	movlw		0x07		; Turn comparators off and enable
	movwf		0x1f		; pins for I/O functions       
        bsf 		INTCON, GIE, ACCESS

gie01:

	bcf		INTCON, GIE
	btfsc		INTCON, GIE
	goto		gie01
	
	clrf		PORTA
	clrf		PORTB
	clrf		PORTC
	clrf		PORTD
	clrf		PORTE
	
	movlw		b'00000111'
	movwf		ADCON1

	BSF   		INTCON, GIE
	BSF		INTCON, PEIE
	BSF 		INTCON, 4

	MOVLW   	.8    		;      
    	MOVWF   	Counter		; Counter = 8
	CALL		InitTmr1	; Init timer1

START:  				; Main loop         
     	CALL    	CheckTmr1	; Check if tmr1 is done
	movwf		0x22		; Move returnvalue to register
	btfsc		0x22,0		; Is it 0, jump next line.
	CALL		CheckCounter	; Is it 1, Check counter.
	CALL		DispLCD		; Display values on LCDs
	goto 		START

CheckTmr1
      	BTFSS   	PIR1, TMR1IF    ; Timer1 Overflow?    
     	RETLW 		0x0          	; Still going, return 0
   	RETLW          	0x1    		; Time's up!   

CheckCounter:
	DECFSZ		Counter, F	; Decrease CounterA * 500ms
	GOTO		Jump1		; If not zero Jump1
	GOTO		Jump2		; If zero Jump2
Jump1:	CALL		InitTmr1	; Restart timer
	RETURN				; Return
Jump2:	MOVLW   	.8    		; Reset Counter = 4
    	MOVWF   	Counter		; Counter = 2
	CALL		TimesUp		; Do the thingy
	CALL		InitTmr1	; Restart timer
	RETURN				; Return

DispLCD
					; Display part 0/1 on displ 1
	MOVF		Ones, W		; Put Ones into W
	ADDWF		Ones, W
	CALL		LCD10		; Translate W into display10
	MOVWF		Disp10		; Save	
	MOVF		Ones, W
	ADDWF		Ones, W
	CALL		LCD20
	IORWF		Disp10, W	; Add together
	
	BCF		PORTA, 0
	BSF		PORTA, 1	; Turn on part 0 for disp 1,2
	MOVWF		PORTB		; Display part 0 on disp 1,2

	MOVF		Ones, W		; Put Ones into W
	ADDWF		Ones, W
	CALL		LCD11		; Translate W into display11
	MOVWF		Disp11		; Save
	MOVF		Ones, W
	ADDWF		Ones, W
	CALL		LCD21
	IORWF		Disp11, W	; Add together

	BCF		PORTA, 1
	BSF		PORTA, 0	; Turn on part 1 for disp 1,2
	MOVWF		PORTB		; Display part 1 on disp 1,2

	RETURN				; Done

LCD10
	ADDWF		PCL, F				
	RETLW 		b'00010110' 	; 0:0
	RETLW 		b'00001100' 	; 1:0
	RETLW 		b'00011100' 	; 2:0
	RETLW 		b'00001100' 	; 3:0
	RETLW 		b'00001010' 	; 4:0
	RETLW 		b'00001110' 	; 5:0
	RETLW 		b'00011110' 	; 6:0
	RETLW 		b'00000000' 	; 7:0
	RETLW 		b'00011110' 	; 8:0
	RETLW 		b'00001010' 	; 9:0

LCD11
	ADDWF		PCL, F
	RETLW 		b'00001110' 	; 0:1
	RETLW 		b'00000000' 	; 1:1
	RETLW 		b'00001010' 	; 2:1
	RETLW 		b'00001110' 	; 3:1
	RETLW 		b'00001100' 	; 4:1
	RETLW 		b'00000110' 	; 5:1
	RETLW 		b'00000110' 	; 6:1
	RETLW 		b'00001110' 	; 7:1
	RETLW 		b'00001110' 	; 8:1
	RETLW 		b'00001110' 	; 9:1

LCD20
	ADDWF		PCL, F
	RETLW 		b'11100000' 	; 0:0
	RETLW 		b'01100000' 	; 1:0
	RETLW 		b'11000000' 	; 2:0
	RETLW 		b'11100000' 	; 3:0
	RETLW 		b'01100000' 	; 4:0
	RETLW 		b'10100000' 	; 5:0
	RETLW 		b'10100000' 	; 6:0
	RETLW 		b'11100000' 	; 7:0
	RETLW 		b'11100000' 	; 8:0
	RETLW 		b'11100000' 	; 9:0

LCD21
	ADDWF		PCL, F
	RETLW 		b'10110000' 	; 0:1
	RETLW 		b'00000000' 	; 1:1
	RETLW 		b'01110000' 	; 2:1
	RETLW 		b'01100000' 	; 3:1
	RETLW 		b'11000000' 	; 4:1
	RETLW 		b'11100000' 	; 5:1
	RETLW 		b'11110000' 	; 6:1
	RETLW 		b'00000000' 	; 7:1
	RETLW 		b'11110000' 	; 8:1
	RETLW 		b'11000000' 	; 9:1

TimesUp
	MOVLW		b'00000001'
	XORWF		PORTD, F
	MOVF		0x21, W		; RPM
	MOVWF		DHexVal		; Display value
	CLRF		0x21		; Clear out, start over
	CALL		HexToDec	; Convert Hex to Dec
	RETURN

HexToDec				; Convert Hex to dec
	CLRF		Ones
	CLRF		Tens
	movf		DHexVal, W	; Get hex value to convert
	movwf		Ones
repeat:	movlw   	.10
	subwf		Ones, W
	btfss		STATUS, C
	RETURN				; Done converting
	movwf		Ones
	incf		Tens, f
	goto 		repeat

InitTmr1
	BCF     	T1CON, TMR1ON   ; Stop Timer1    
     	BCF     	PIR1, TMR1IF    ; Clear Timer1 overflow flag  
	BCF     	T1CON, 4  
	BCF     	T1CON, 5  
     	BSF     	T1CON, TMR1ON   ; Start Timer1   
	RETURN

IntRupt
	MOVWF		SaveW		; Save what's in W
	MOVLW		b'00000010'
	XORWF		PORTD, F
	INCF		0x21, f		; Increase RPM counter
	MOVF		SaveW, W	; Restore W
	BCF 		INTCON, 1	; Reset int flag
	RETURN				; And return

	end

Sorry, that I'm using address numbers in some parts of my code.

The INT0 pin is connected to a IR-module, counting 0x21 that will be converted to decimal numbers every 2 sec. I have an old LCD display connected to the PORTB port 1-7. PORT A0 and A1 is used to control which part of the display to activate. It's counting like it should but when I debug it in ISIS PCL jumps to the interrupt address when calling the LCD20 making it go wild if W contains >= 3 (in ISIS >= 6), I thought it could be a paging thing and tried to add PCLATH code with no success. (maybe it's just lack of knowledge)

I have also tried to put some NOP in fron of the LCD20 routine to make it move in address, then it's working in ISIS but not in the real thing!

Well, I don't know if I've covered everything here.. but I hope someone could see the problem?

/ Morgan
 
Last edited:

Hi,

Will let Brian go into the code detail as he is more familiar with your project.

Would just say a few things about you using the 18F4550 chip - for a start why ..?
Are you thinking that because its a USB chip that you can use USB ..? - in short you can really only use its USB function if you are programming in C - have never seen any code for assembler.

Your 16F code needs to be updated to match the differences of the 18F chips which is rather different in many small ways - different locations for the two levels of interrupt , high and low at 0x008 and 0x018 etc.
The ram banking and memory paging is also different etc , etc.

You need to search for the 16F to 18F migration documents from Microchip which will help identify all the areas you should address.

As you have just started coding, moving to a different chip series is perhaps not a good move so soon.
 


You are right again, I'm not going to use USB just trying to teach myself more about the P18F at the same time. But, yes I must go back to the P16 again because it suites my project better.

/ Morgan
 

You are right again, I'm not going to use USB just trying to teach myself more about the P18F at the same time. But, yes I must go back to the P16 again because it suites my project better.

/ Morgan

Hi,

well if you want to try the 18F look at the 2520 or 4520 which do not have the USB elements to worry about.
He is a typical opening bit of code for the 18F, you might spot some of the differences, though most of the code is the same, but the 18F instruction set has a lot more useful things like movff etc.

Code:
;	 =====================================================    				  *

;	Processor Type
;	==============

	LIST P=18F4520,r=hex,n=80,x=off,st=off
	errorlevel -302		; no bank warnings

	#include <P18F4520.INC>	



;******************************************************************************
; 
;	Configuration bits 
;	==================
  
; specified here are changes to the .inc file defaults

 CONFIG OSC=INTIO67, PWRT=ON, BOREN=OFF, WDT=OFF, MCLRE=OFF, LPT1OSC=OFF, PBADEN=OFF
 CONFIG LVP=OFF, XINST=OFF, DEBUG=OFF






;******************************************************************************
;
;	Variable definitions
;	====================


;	Bank0 variables  0x000 to 0x07F access ram 
;	(4550 bank0 to 0x05F only)				

	cblock  0x000


	WREG_TEMP	;variable used for context saving 
	STATUS_TEMP	;variable used for context saving
	BSR_TEMP	;variable used for context saving


	ENDC


;	Bank1 variables 0x100 to 0x1FF

	cblock	0x100		; BANK1			
	pntr
	offset
	dval
	WORK1


;  last address entered   max FF
	endc				


; *****************************************************************************
;
;	EEPROM data
;	===========

; Data to be programmed into the Data EEPROM is defined here
; 


	org 0Xf00000
	de 0X10,0X00,0X15,0X14,0x20,0X22,0X19,0X13	;de00
	de 0X30,0X00,0X10,0X20,0X22,0X15,0X10,0X30  ;  08
	de 0X21,0X30,0X00,0X00,0X00,0X00,0X00,0X00	;  10
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  18
	de 0X00,0X00,0X15,0X15,0X00,0X00,0X00,0X00  ;  20
	de 0X00,0X00,0X10,0X10,0X10,0X10,0X10,0X10  ;  28
	de 0X10,0X10,0X10,0X10,0X10,0X10,0X10,0X10  ;  30
	de 0X10,0X10,0X10,0X10,0X10,0X10,0X10,0X10  ;  38
	de 0X10,0X10,0X10,0X10,0X10,0X10,0X00,0X00  ;  40
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  48
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  50
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  58
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  60
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  68
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  70
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  78
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  80
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  88
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  90
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  98
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  A0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  A8
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  B0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  B8
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  C0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  C8
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  D0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  D8
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  E0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  E8
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  F0
	de 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00  ;  F8





;******************************************************************************
;
;	Reset vector
;	============

		ORG	0x0000
		nop
bootup	goto	Main		;go to start of main code

;******************************************************************************
;
;	High priority interrupt vector
;	==============================

; This code will start executing when a high priority interrupt occurs or
; when any interrupt occurs if interrupt priorities are not enabled.

		ORG	0x0008

		bra	HighInt		;go to high priority interrupt routine

;******************************************************************************
;
;	Low priority interrupt vector
;	=============================
 
; This code will start executing when a low priority interrupt occurs.
; This code can be removed if low priority interrupts are not used.

		ORG	0x0018

;		movff	STATUS,STATUS_TEMP	;save STATUS register
;		movff	WREG,WREG_TEMP		;save working register
;		movff	BSR,BSR_TEMP		;save BSR register

;	*** low priority interrupt code goes here ***


;		movff	BSR_TEMP,BSR		;restore BSR register
;		movff	WREG_TEMP,WREG		;restore working register
;		movff	STATUS_TEMP,STATUS	;restore STATUS register
		retfie

;******************************************************************************
;
;	High priority interrupt routine
;	===============================

; The high priority interrupt code is placed here to avoid conflicting with
; the low priority interrupt vector.


HighInt	nop

hisrend	retfie	FAST



;******************************************************************************
;******************************************************************************
;
;	Start of main program
;	=====================

; initialisation of system, clear RAM , setup i/o ports



Main	movlw	b'01100010'		; set internal osc to 4 mhz
		movwf	OSCCON


ramclr	movlb	D'1'			; define bank1, so it and bank 0/15 (access) 
								; can be addressed without banking
 		clrf 	INTCON			; clear interupts
 		clrf	STATUS			; reset to bank 0
 

 		clrf	FSR1H			; FSR routine to clear ram banks 0 -4 only
		clrf	FSR1L		
clrram	clrf	POSTINC1		; clear location and inc
 		movlw	0x05			; now in bank5 ?
 		subwf	FSR1H,W
 		bnz		clrram			; carry on clearing if not at bank5
 

Whoopee! Someone has confidence in me ! Thanks wp100.

I agree fully with the other contributors about code migration but if you want to stay with PIC18 devices I can give a few pointers. I have not tried to assemble the code so treat this as clues, not answers:

1. The PIC18 series does not use banked registers, at least not in the same way as the 16F series. Each register has it's own unique address so there is no need to set the selection bits.
2. PIC18 has it's own way of accessing tables which does not have boundary restrictions like on PIC16. Look up the 'TABL' instruction for your options.
3. There is an extra interrupt vector in PIC18 so you can have 'normal' or high priority interrupts, you need to check which vector you are using or disable the high priority one for compatibility.

Actually, I would have expected the problem you report in the PIC16 version but not the PIC18 version. It sounds like one of your tables crosses a page boundary so when you jump into it by adding W to the PCL, you go beyond it's 8-bit maximum and roll around to a lower value. For example, if PCL was already 0xf0 and you added 0x14 to it you would jump to address 0x04 instead of 0x104.

Brian.
 
Thank you.. both of you wp100 and Brian!

I will dig into your code wp100, nice.

Brian, That is what I was thinking about the paging with table crossing two pages. I simply tried to move the code with several NOP (solved the issue only in ISIS simulator but not on the real thing) but there seems to be more problems when the programmer dosn't handle the PIC18F4550 properly because it just writes a bit of code and quits early in the process of writing the program I've noticed.

Well, I'm going to buy a PICKit2 instead of my Velleman VM134 and try again just to see if this also is a faulty part.

Thanks again guys, I'll go back to the drawingboard.. and I must read your replies a couple of times more to comprehend all of it.
 
Last edited:

I have to ask the question, why are you simulating in ISIS when you assemble the program in MPLAB which has it's own simulator?
I use the PICKit2, in fact have two of them and a Salae logic analyzer, all hooked up to one PC. I find them excellent, especially when I can hook them to two processors in different parts of circuits and watch the signals between them on the analyzer.

Can you clarify, when you see the table/page problem, is it in the 16F628 or in the 18F4550 you see the problem? I've gotten confused over the debugging and the migration issues.

Brian.
 

Hi,

Well good move about getting the Pickit2 - a great buy - just make sure you buy the genuine Microchip one.

This Zif board is great value and well made, though a little interface cable makes connection a lot easier. **broken link removed**

For the 18F chips there is no Paging to worry about and all the system registers are in just one Bank so no Banksel to bother with.
Also the Ram banks are so big you don't normally have to worry about changing banks - the example code I sent allows you to have access to 384 bytes of user ram, banks 0 Access and bank 1, before changing to another Bank.

When using tables use this bit of code with them all - was given it by the Microchip forum guys.

Code:
; ***************************************************************************
;
;	LOOKUP TABLE 18F
;	==============

	

disptble movwf	TABWORK			; sets system for 18F lookups - 2 byte calls
	bcf	STATUS,C
	rlcf	TABWORK,F
	movlw	HIGH(table1)
	btfsc	STATUS,C
	incf	WREG,W
	movwf	PCLATH
	movlw	LOW(table1)
	addwf	TABWORK,W
	btfsc	STATUS,C
	incf	PCLATH,F
	movwf	PCL  

table1 retlw 0x30	; 0
	retlw	0x31	; 1
	retlw	0x32	; 2
	retlw	0x33	; 3
	retlw	0x34	; 4
	retlw	0x35	; 5
	retlw	0x36	; 6
	retlw	0x37	; 7
	retlw	0x38	; 8
	retlw	0x39	; 9
	retlw	0x41	; a
	retlw	0x42	; b
	retlw	0x43	; c
	retlw	0x44	; d
	retlw	0x45	; e
	retlw	0x46	; f
 
I have to ask the question, why are you simulating in ISIS when you assemble the program in MPLAB which has it's own simulator?

My answer is, that I've learnt ISIS better and stuck with it.


Ok, that sounds great, and USB instead of COM! I'll order one tomorrow.

Can you clarify, when you see the table/page problem, is it in the 16F628 or in the 18F4550 you see the problem? I've gotten confused over the debugging and the migration issues.

Brian.

Sorry about that Brian, I was laborating a bit to much and got the late night idea of migrating my code to the 4550. I didn't see the table/page problem, but I took a guess that it could be the problem, and yes it was on the 4550 this problem occured. First of all Im sure now that the biggest of all problems is with my programmer that is messing it up and only writes a part of the program to the 4550 PIC. So I'll guess I have to wait and try this part again when my PICKit2 has arrived on this one.

But I'll go back to a 16F pic on this project because that will be just enough.

/ Morgan

---------- Post added at 00:30 ---------- Previous post was at 00:21 ----------

Hi,

Well good move about getting the Pickit2 - a great buy - just make sure you buy the genuine Microchip one.

This Zif board is great value and well made, though a little interface cable makes connection a lot easier. **broken link removed**

Thanks for the information, I will check on that.


Well then it just have to be my programmer first of all that is writing a bit of the programcode and exits without a warning or error.. hmm


Thank you very much for the code snippet, great information that will come in handy.

/ Morgan
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…