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.

50Hz Clock Pulse ....Help

Status
Not open for further replies.

satheesh916

Newbie level 4
Joined
Aug 19, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
K.S.A
Activity points
1,322
Hi, I'm new with microcontrollers and I'm making a 12 hour clock using MM5387(LM8361) and it needs clock input of 50Hz. I got a couple of PIC16F84A and want to generate 50Hz(20ms) clock pulse from it, but don't know how to write the code for the PIC. If someone please help me with the code it will be a great use to me. I tried searching internet and didn't get anything useful. The Clock is working good with 50Hz AC pulse but I need to use 16F84 and also learn from it.. So someone please help me with the code for the same..
 

Hi,

mikroC:
Code:
void main(void){
     TRISB = 0; //PORTB output
     PORTB = 0; //Clear PORTB
     while (1){
           PORTB.F0 = ~PORTB.F0; //Invert PORTB 0
           delay_ms(20); //20ms delay
     }
}

mikroBASIC:
Code:
program Clock_50Hz

main:
     TRISB = 0 'PORTB outpu
     PORTB = 0 'Clear PORTB
     while true
           PORTB.B0 = not PORTB.B0 'Invert PORTB0
           delay_ms(20) '20ms delay
     wend
end.

I can provide ASM if wanted.
Set config settings as:
Code Protect: off
PWRTE: off
Watchdog Timer: off
Crystal: XT
Use crystal of 4MHz or anything you want.

For mikroBASIC/mikroC compilers:
https://www.mikroe.com

I hope you can construct the circuit. Connect Vcc to 5v, gnd to 0v, and use PORTB0(RB0) as output(pin 6).

Hope this helps.
Tahmid.
 

Hi Tahmid, can you please provide me the asm file too..Thanks once again for your response.
 

Hi,
Code:
	LIST P=16F84A
	#INCLUDE <P16F84A.INC>
	__CONFIG 0x3FF1

	ORG 0x00
	GOTO MAIN

	CBLOCK 0x20
		REG1, REG2
	ENDC          

DELAY
	MOVLW	.250
	MOVWF	REG1
	MOVLW	.13
	MOVWF	REG2
	DECFSZ	REG1, F
	GOTO	$-1
	DECFSZ	REG2, F
	GOTO	$-3
	NOP
	RETURN

MAIN
	BSF		STATUS, RP0
	CLRF	TRISB
	BCF		STATUS, RP0
	CLRF	PORTB
LOOP
	BSF		PORTB, 0
	CALL	DELAY
	NOP
	BCF		PORTB,0
	CALL	DELAY
	GOTO	LOOP
	END
Hope it helps.
Tahmid.
 

Thanks Tahmid..
Also if you could send me the hex file for the same it would be a lot more helpful.
 

Thanks once again Tahmid for your valuable time. I will try it and let you know. Please do keep in touch
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top