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.

More PIC Usart help!

Status
Not open for further replies.

00morrisd

New Member
Hi guys,

Asked for some help regarding a pic to pc communication using rs232 and serial port a few weeks ago.

Manged to get all my components ordered and finished building the thing last week, now for my one true hate, programming! Need to send a worded message through the USART function of the PIC16F88.

I know what I want my pic to do, but I can only say it like this, have no idea how to put into a code.....

Check pins 1, 2 and 3.

If pin 1 = 0
and pin 2 = 1
and pin 3 = 1

send string "FAIL" to pin 11


Thats basically it although I know it will take a bit more than that. The same procedure will be repeated about 5 times for various '1' and '0' combinations.

Please, please can someone help me bring this into some kind of code.

The main things I need to know are:-

1 - What kind of program do I make the code in? (mikroC)

2- What information do i need to do this? (port numbers etc.)

3- How long will the code be/what functions should i use?

4- What program do I use to convert and download the program to the pic?

Thanks for your help, I have been directed to online tutorials before but they arent much use to me because i just simply dont understand the code and what its doin!
 
I can help, but this will get messy.

The 16F88 is a real old chip and a pain to use. I did, however, write UART code in HI-TECH C (should work without problems in mikro C) for the 16F886 (should work on 16F88). The code is very simple and makes use of the hardware UART module in the 16F886.

1. Does your chip have a hardware UART? Or does this need to be implemented in software?

2. You can use HI-TECH C compiler (I recommend this over any other compiler for the 16F series, it's the best compiler out there for this series of PIC microchip).

3. As for the code/functions, it's VERY easy if you have a hardware UART in your microcontroller. If not, then things will get messy.

4. Do you have a PIC programmer device? I recommend the PICKIT2. If you buy that, you don't even need the MAX232. All you do with the PICKIT2 is hook it up directly to the PIC's UART lines and you can use UART that way. With the PICKIT2, you can use the PICKIT2 software. If you're not using the PICKIT2, then there are a lot of programmer devices and software you can use. Again, I HIGHLY recommend you go and buy the PICKIT2 if you don't have it already.

And I understand that it can be frustrating when you ask for help and all you get are links to lame tutorials. Let's see if I can be of any help.
 
Last edited:
The 16f88 is the latest 18 pin 16 series pic available. It has many features including a hardware UART. I prefer BoostC.

Mike.
 
Last edited:
Manged to get all my components ordered and finished building the thing last week, now for my one true hate, programming! Need to send a worded message through the USART function of the PIC16F88.

I know what I want my pic to do, but I can only say it like this, have no idea how to put into a code.....

If you keep that attitude towards programming you are going to be asking other people to program for you, for the rest of your life.

My advice would be, bite the bullet and study and learn how to do simple programming.:)

Its pointless building a MCU hardware project if you havn't a clue on how to program it.!
 
If you keep that attitude towards programming you are going to be asking other people to program for you, for the rest of your life.
My advice would be, bite the bullet and study and learn how to do simple programming.:)
Its pointless building a MCU hardware project if you havn't a clue on how to program it.!

I agree! Thats what I am doing right now, learning MCC, writing my program to fit the Junebug to get it going, then I will change it for the final project. I want to collect adc and port data and send it out the USART. I am not sure yet if I will do a timed cycle or ask for it via the USART then send. There are so many examples out there to learn from.
After the first couple it will get easier. I am picking this up after 20 years of no programming.
Start plugging and good luck.
ike
 
Can anyone pls tell me what is the maximum size of the input buffer of the pic 18f4550 eusart ... is it programmable ????
 
There is no hardware buffer on the pic chips there is only a holding register which must be read before the next byte arrives. You have to implement a buffer in software.

Mike.
 
usart pic

thanks for ur code mike ...
i came across the followin code in the c18 library functions manual

char inputstr[10];
getsUSART( inputstr, 5 );

does the above code also require the fifo buffer ..
 
i need to send the hex data '1E' from pic 18f 4550 to another device through usart ...?? what is the corresponding character for '1E' ... how to do that in C18 ?
 
delay

sir,
can u check what is wrong with my program,i couldn't get delay correctly.
LIST P=16F877A
STATUS EQU H'03
PORTB EQU H'86
RP1 EQU H'6
RP0 EQU H'5
TRISB EQU H'86
INTCON EQU H'8B
T1CON EQU H'10
TMR1L EQU H'0E
TMR1H EQU H'0F
PIE1 EQU H'8C
PIR1 EQU H'0C
TMR1IF EQU 1
TMR1IE EQU 1
GIE EQU 8
PR2 EQU 92H
ORG H'00
GOTO START
ORG H'50
START:
BSF STATUS,RP0
MOVLW H'00
MOVWF TRISB
BCF STATUS,RP0
MOVLW H'18
MOVWF PORTB
CALL DELAY
MOVLW H'03
MOVWF PORTB
CALL DELAY
MOVLW H'12
MOVWF PORTB
CALL DELAY
MOVLW H'03
MOVWF PORTB
CALL DELAY
MOVLW H'06
MOVWF PORTB
CALL DELAY
MOVLW H'09
MOVWF PORTB
CALL DELAY
MOVLW H'0C
MOVWF PORTB
CALL DELAY
MOVLW H'09
MOVWF PORTB
CALL DELAY
GOTO START
ORG120H

DELAY: BSF INTCON,GIE
BCF PIR1,TMR1IF
BSF PIE1,TMR1IE
MOVLW H'1D
MOVWF TMR1L
MOVLW H'FB
MOVWF TMR1H
MOVLW B'00001011
MOVWF T1CON
LOOP:
BTFSS PIR1,TMR1IF
GOTO LOOP
RETURN
END
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top