Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using watch in MPLAB

Status
Not open for further replies.

RMIM

Member
My head is spinning, please help.

movlw d'255'
movwf PORTA
movwf PORTB


when I 'watch' them I see that WREG goes to 255, PORTB goes to 255 but PORTA goes to 208.

I was expecting them both to go to 255.

What am I not understanding?

Thanks.
 
Hi,

You do not say what chip you are using, but have you set PortA to Digital from the default Analogue or Comparator input ?

Does you chip have 8 bits on PortA ?
 
Last edited:
Hi,

You do not say what chip you are using, but have you set PortA to Digital from the default Analogue or Comparator input ?

Does you chip have 8 bits on PortA ?

Thanks for the reply

chip is PIC16F628A

as for digital/analogue/comparator im not sure.

these are my only lines

LIST p=16F628a
include "P16F628a.inc"

and

BSF STATUS,5
movlw b'00000000'
movwf TRISB
movwf TRISA
 
Hi,

The code below will load FF to PORTA, however not all pins on the 628A can be used as outputs.

First you must set up the Configuration line to Set the Internal Oscillator On so allowing RA6 and RA7 to be used as Digital pins instead of an input for the crystal oscillator.

You then must turn off the default Comparator function, to allow all PortA pins to be used as Digital outputs

Finally RA5 can only be used as a Digital Input, and only when Mclre is turned off in the Config.

So the final result on PortA for the 255 input will be 0xDF or 223. No value in bit RA5


You are just using the code in the most basic way possible, have a look at the TEMPLATE file for the 628A in MPlab /Asm directories, which give you all the basics.


Code:
	LIST p=16F628a
	include "P16F628a.inc"
	
	__CONFIG   _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT 




	
	banksel	TRISA	    ; select bank1		
	movlw b'00000000'
	movwf TRISB
	movwf TRISA 
	banksel	PORTA		; return to bank 0


	
	movlw	0x07		; TURN OFF PORTa COMPARATOR 
	movwf	CMCON
	
	movlw d'255'
	movwf PORTA
	movwf PORTB
	NOP
	NOP
	end
 

Attachments

  • ScreenShot002.jpg
    ScreenShot002.jpg
    35.9 KB · Views: 141
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top