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.

Need Help With [ TX/RX ] For PIC16F628 - Please Look Into IT

Status
Not open for further replies.

Ghassan Al-Mutawa

Junior Member level 3
Junior Member level 3
Joined
Oct 9, 2005
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bahrain
Activity points
1,574
pic16f628a tx

Hi There Friends

I obtained a picstar plus programer from microchip to program all my pic's for the score board project.

well here is my problem , i made an interface program using visual basic to give a serial output of 8 bits data with 9600 kbaud rate

in my pic i used the internal oscillator [ 4 mhz ], set the BRG =1 [ spbrg = 19h ]
set the tx and rx / but didnt work !!!

i tried doing an assambly code to recive the code form the pc, but it didnt work

so if any of you have a sample program of a pic16f628

for serial tx & rx please attach it here i need to see it so i can solv my problem

===============
at the end i thank you all of you for this nice helpfull forum and give a special thanks for those who read my problem and tried to solve it for me. thank you :|
 

pic16f628 sample program in c

Maybe this will be of any use to you ..
**broken link removed**
Regards,
IanP
 

serial communication with pic16f628 to vb6

this isint the one

i want to know haw to make the rx and tx of the pic 16f628 work

but thanks for trying to help me ! :wink:
 

pic16f628 serial port tx rx

Hola Ghassan,

Please show your code so someone could check for eventual errors. Anyway, I don't think using RC oscilator would be good enough.

Just three weeks ago, used the 16F877 (for USART, it is the same as your micro) and was really SIMPLE.

Do something for others to help you.
 

pic16f628 serial communication

Okay Sir Here is my code, the wanted baud rate is 9600 this was just to test the chip if the rx program is working or not , i tested it on board but didnt work hope you can tell me whats the problem, thank you all of you

;===================================================
; GETTING VARIABLES READY
;===================================================

RXSTA EQU 0X18
TXSTA EQU 0X98
RXREG EQU 0X1A
TXREG EQU 0X19
SPBRG EQU 0X99
PIE1 EQU 0X8C
PIR1 EQU 0X0C
TRISA EQU 0X85
TRISB EQU 0X86

PORTA EQU 0X05
PORTB EQU 0X06

STATUS EQU 0X03
FREE1 EQU 0X20
FREE2 EQU 0X21
FREE3 EQU 0X22

;===================================================
; CONFIGRATION
;===================================================

ORG 0X08 ; START OF PROGRAM

MOVLW B'10010110' ; BINARY CODE FOR RXSTA
MOVWF RXSTA ; SET THE RX PORT

BSF STATUS,5 ; JUMP TO BANK 1 [ STATUS = 03H ]

MOVLW B'00000010' ; BINARY CODE FOR PORT B
MOVWF TRISB ; SET ALL PORTB OUT BUT PIN 1 RX IN

CLRF TRISA ; SET ALL PORT A TO OUTPUT

MOVLW B'00110000' ; BIT5 ENABLE TX INTRUPT, BIT4 ENABLE RX INTRUPT
MOVWF PIE1 ; SET THE INTRUPT ENABLES [ PIE1 = 8CH ]

MOVLW 0X19 ; VALUE EQUALS TO 25 DECIMAL
MOVWF SPBRG ; MOVE TO SPBRG, AND SET BAUD RATE 9600 K [ BRGH = 1 ] FOR 4 MHZ

MOVLW B'00100110' ; BIT 1, I AM NOT SHURE OF IT
MOVWF TXSTA ; SET THE TXSTA TO 8 BIT ASYNCHRONOUS TRANSMITION

BCF STATUS,5 ; JUMP TO BANK 0

;===================================================
; THE WANTED PROGRAM : JUST EXAMPLE
;===================================================

START

BTFSC PIR1,5 ; IF THE RX REGISTER IS FULL
CALL GET ; THEN CALL GET FUNCTION
MOVFW FREE1 ; STORED DATA FROM RX
MOVWF PORTA ; OUT FROM PORTA TO LEDS
GOTO START ; START THE SAME PROCESS AGAIN

;===================================================

GET

MOVFW RXREG ; THEN MOVE RX DATA TO W REGISTER
MOVWF FREE1 ; STORE THE DATA IN 0X20

RETURN

;===================================================
END
;===================================================
 

spbrg 19h

Hi !

Working with high baud rates and internal oscillators is not a good choice. The internal oscillator is not stable and accurate, so you are going to get high error baud rates, so the serial communication will not work properly. Try to configure the communications to lowest baud rate (150 or 300 bps can work with internal oscillator) to check if your routine is correct. If it works, the problem is for sure the oscillator. To work with high baud rates, you should use a crystal oscillator, much more stable and accurate.

Good luck.
 

pic16f628 pulse width changer

at least can any one tell me if my program should work or not !! is my program all right or is it wrong ??

well as for the 4mhz internal oscillator l i will change it to find out but need some body to tell me if it is working
 

programming sample tx rx

Salam-o-Alikum!
Here is my code that i have successfully used with 4MHz external oscillator. Serial communication with the internal oscillator is not recommended.
The code is in C language but you can easily generate the assembly code.


void setup_usart(void)
{

TXSTA = 0X04;
RCSTA = 0X10;
SPBRG = 207;(decimal value)
SPEN = 1;//enable serial port
TXEN = 1;//enable_transmit
}
/**************************************************************/
char getch (void)
{
while(!RCIF)
{
}
RCIF = 0;
return(RCREG);
}
/***************************************************************/
void putch (char c)
{
TXREG = c;
DelayUs(100);
while(!TXIF)
{
}
TXIF = 0;
};

This code will establish a serial communication at 1200 baud rate.
I am also providing a free to download software for communication with the PIC.
Once the controller starts communicating with this software then you use your own software so that you are sure that at least one thing is working.
Another thing is that there is no need to define the special function registers as you have done in your code just include the relevant processor include file.

If you still find it difficult then donot hesitate to ask.

Allah hafiz.
 
Re: Need Help With [ TX/RX ] For PIC16F628 - Please Look Int

Hi Waseem,

I have also problem decoding pulses. Please see my lately posted code under the topic "Measuring Pulse Width". It is a code that will decode 2 sets of pulses from a transmitter. If the code is correct, corresponding LED will light. Please look at it and need help on this. Thanks a lot...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top