Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC12f508 port programming problem

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Full Member level 4
Joined
Nov 19, 2003
Messages
208
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,763
hi
i m using pic12f508 by assembly language.

a strange thing is, its datasheet tells that there is no any "TRIS" reg. in this. but when i run MPLAB 8, TRIS reg shows but when i want to mov data in it by following syntax, it shows error when building.

MOVLW 80h

MOVWF TRISIO

(i used TRISGPIO as well but result is same)

where as same code works on pic12f629

help me please
 

Try this:

Code:
;******************************
MOVLW  80H
TRIS      GPIO;
;******************************
MOVLW  00H
MOVWF  GPIO
;******************************

My basic "hello world" example:

Code:
;**********************************************************************
	list      p=12c508
	#include <p12c508.inc>
;**********************************************************************
	__CONFIG   _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC
;**********************************************************************
#DEFINE		LED1		GPIO,0
#DEFINE		LED2		GPIO,1
#DEFINE		BOTAO2		GPIO,2
#DEFINE		BOTAO1		GPIO,3
#DEFINE		LED3		GPIO,4
#DEFINE		LED4		GPIO,5
;**********************************************************************
	CBLOCK	0X07
		TEMP1
		TEMP2
	ENDC
;**********************************************************************
	ORG     0x1FF
;**********************************************************************
	ORG     0x000
	GOTO	CONFIGU
;**********************************************************************
CONFIGU
	MOVWF   OSCCAL
	MOVLW	B'00001100'
	TRIS	GPIO
	MOVLW	B'00000000'
	MOVWF	GPIO
;**********************************************************************
MAIN
	BTFSS	BOTAO1
	CALL	VERDADE1
	CALL	FALSO


	NOP

	BTFSS	BOTAO2
	CALL	VERDADE2
	CALL	FALSO

	NOP
	GOTO 	MAIN	
;**********************************************************************
FALSO
	MOVLW	0X00
	MOVWF	GPIO
	NOP
	RETURN
;**********************************************************************	
VERDADE1
	BSF		LED2
	CALL	DELAY
	BSF		LED1		
	BCF		LED2
	CALL	DELAY
	BSF		LED1
	RETURN
;**********************************************************************
VERDADE2
	BSF		LED4
	CALL	DELAY
	BSF		LED3		
	BCF		LED4
	CALL	DELAY
	BSF		LED3
	RETURN
;**********************************************************************	
DELAY 							; 100ms delay
	MOVLW	0X1E
	MOVWF	TEMP1
	MOVLW	0X4F
	MOVWF	TEMP2
DELAY_0
	DECFSZ	TEMP1, F
	GOTO	$+2
	DECFSZ	TEMP2, F
	GOTO	DELAY_0
	GOTO	$+1
	NOP
	RETURN
;**********************************************************************
	END
;**********************************************************************
 
Last edited:
hi nagakiller thanks alot. one more thing i want to ask 1 more thing.
can i use pic12f508 for communication with serial port of PC?
if yes then please tell how?

- - - Updated - - -

hi nagakiller thanks alot. one more thing i want to ask 1 more thing.
can i use pic12f508 for communication with serial port of PC?
if yes then please tell how?
 

Hi,

That chips does not have an inbuilt USART section to take care of a typical serial interface.

However you can still send out serial data by using a Software Usart, also known as 'Bit Banging'

See this link for details of serial data and an example of bit banging, though it would need a bit of work to change the code for your chip / gpios
**broken link removed**

If you Google '12F508 bit banging ' you might find some ready to run code.

You will need a max232 chip and serial cable or a TTL to USB converter cable to connect to the PC, the latter being the cheaper and easier method.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top