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.

Visual basic, PIC 16F84A ,3 LED

Status
Not open for further replies.

revenger82

New Member
is it possible to 'on' 3 different LEDsby clicking to 3 command button of visual basic? Those LED are connected to PIC 16F84A and a serial port is connected between the pc and the PIC16F84A.
 
revenger82 said:
is it possible to 'on' 3 different LEDsby clicking to 3 command button of visual basic? Those LED are connected to PIC 16F84A and a serial port is connected between the pc and the PIC16F84A.

Yes perfectly possible, and quite easy to do.

However, as usual, unless you already have a box of 16F84's you should use it's 'modern' replacement the 16F628 instead, cheaper, and better spec.

Check my tutorials for examples of RS232 interfacing using a PIC.
 
I have a smilar question, and I have looked at Goodwin's tutorial.

However, the tutorial does not use hardware USART. is there a tutorial for hardware USART on 16f628?
 
MathGeek said:
I have a smilar question, and I have looked at Goodwin's tutorial.

However, the tutorial does not use hardware USART. is there a tutorial for hardware USART on 16f628?

The last section of the tutorial uses the hardware UART, but on the 16F876/7, however it's identical to use on the 16F628 - so the code applies to the 628 as well.
 
Thanks. I have looked at the code. but, to be honest with you, I still don't understand the fundamentals of USART.

HELP!!!!
 
MathGeek said:
Thanks. I have looked at the code. but, to be honest with you, I still don't understand the fundamentals of USART.

What's to understand?.

Code:
;USART Serial routines

SER_INIT
            	BSF     STATUS, RP0           ;select bank 1
     		MOVLW   d'129'                ;9600 baud @ 20 Mhz Fosc +0.16 err
     		MOVWF   SPBRG
     		MOVLW   b'00100100'           ;brgh = 1
     		MOVWF   TXSTA                 ;enable Async Transmission, set brgh
            	BCF     STATUS, RP0           ;select bank 0
     		MOVLW   b'10010000'
     		MOVWF   RCSTA                 ;enable Async Reception
            	RETURN

XMIT_RS232  	btfss   PIR1,	TXIF 	      ;xmit buffer empty?
     		GOTO	XMIT_RS232            ;no, wait
     		MOVWF   TXREG		      ;now send
                RETURN

Rcv_RS232   	BTFSS   PIR1,	RCIF 	      ; check for received data
     		GOTO    Rcv_RS232
                MOVF    RCREG,	W
                RETURN

This is the tutorial USART code, it consists of only three routines, the first sets the hardware up, the second transmits the contents of the W register, and the third waits for and then receives a byte, which is returned in the W register.

If there a particular reason you want to use the hardware USART?.
 
What does BRGH bit do? I understand that if BRGH=1, then it is for "high" baud rates, and BRGH=0, then it is for "low"

But, the mid range manual said,

"The baud rate generator
produces a clock either x16 or x64 of the bit shift rate, depending on the BRGH bit (TXSTA<2>)." page 344.

I don't understand what bit shift rate is.

Edit: One reason I want to learn hardware USART is that it is more elegant and I can save code space for other stuff in the code.
 
Last edited:
The "bit shift rate" is the rate at which bits are shifted one after the other from a register in the UART to the Transmit Data output. It is also the rate at which bits are shifted from the Receive Data line into a register. The reason why the clock needs to be x16 or x64 the bit shift rate is that this is an asyncronous sampled data system. The original character is reconstructed by sampling the Received Data at a rate 16 times higher than the bit rate.
 
MathGeek said:
Edit: One reason I want to learn hardware USART is that it is more elegant and I can save code space for other stuff in the code.

As you can see from the code above, the space savings are pretty minimal, so I suggest you keep BOTH methods in mind - for some uses a software UART is far better!.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top