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.

Grr can't find a software usart!

Status
Not open for further replies.

DexterLB

New Member
I am using Hi-TECH PICC 9.60 PRO compiller, with PIC12F629. And I can't find a software usart routine! All i need is init, sendbyte and receivebyte functions. So, is there an official .h file with these which uses SOFTWARE usart?
 
Why not just write one? It will greatly increase your knowledge of serial communication and pic chips. It's also not that hard to do. There are many examples available on the internet.

Mike.
 
Here is my really crappy software receive in C18.

Code:
unsigned char GetChar(){
unsigned char chr,x;
    TRISAbits.TRISA0=1;
    while(PORTAbits.RA0==1);       //wait for start bit
    Delay10TCYx(30);           //150uS =one and half bit
    for(x=0;x<8;x++){
        chr>>=1;
        if(PORTAbits.RA0==1)
            chr+=0x80;
        Delay10TCYx(20);    
    }
    return chr;
}

See, not too hard, wait for start bit, delay 1½ bits then read in 1 bit each bit time until you have 8.

Mike.
 
Every compiler should provide one in their lib. If you have a bit of skill with c you can port most any to HI-TECH if if HI-TECH does not have one, and it should.

The CCS people have a very good support forum. They have a section for user contributed code. It is often very good. Comes in a few variations for things like not having all bits on the same port etc.
 
I think he was talking about having a struct with pins from different ports all in the same register. Like if you wanted to run a parallel LCD from port a and port b...

3v0 is correct about their forums; CCS do have one of the very best forums... great help. :D

I recall writing serial routines when I tried out HiTech C, but that was so long, and a couple of hard drives ago.. :p

It seemed difficult until I got it, then seemed easy.

When I first got SourceBoost, there was no formatted print, so...

Still, it annoys me that HiTech want so bloody much for the full compiler - For EACH family, and Source Boost (for 16Fxxx and 18Fxxx) is LESS than one tenth the price, and it is as good a compiler ....

SourceBoost Technologies - Home of BoostC Free PIC C Compiler and BoostBasic Free Pic Basic Compiler
 
Last edited:
I know we are talking about UARTs here. As BeeBop said the CCS forum has LCD routines that can use bits from different ports. I was thinking you might find some interesting variations of UART software there too.

Even if you end up writting your own drivers reading code to see how others have done it is a good thing.
 
Dexter,
So sorry it took me so long to remember this link. I took this:
[FONT=Arial, Helvetica, sans-serif]Q. I want a routine to do a serial port in software, because I’m using a low-end PIC.[/FONT]
[FONT=Arial, Helvetica, sans-serif]Go to directory ‘c:\ht-pic\samples’ and look at files ‘serial.c’ and ‘iserial.c’. The second file receives characters into a buffer in the background, using interrupts. Its almost like the hardware serial port on a high-end PIC.[/FONT]
[FONT=Arial, Helvetica, sans-serif]
[/FONT]
[FONT=Arial, Helvetica, sans-serif]from this page,[/FONT]
[FONT=Arial, Helvetica, sans-serif]
[/FONT]PIC micro and C - FAQ
[FONT=Arial, Helvetica, sans-serif]
[/FONT]
[FONT=Arial, Helvetica, sans-serif]on this site, which also has some down-loadable projects with a serial port for both PIC 16Fxxx and 18Fxxx parts.[/FONT]
[FONT=Arial, Helvetica, sans-serif]
[/FONT]
[FONT=Arial, Helvetica, sans-serif]Microchip PIC micros and C - source and sample code
[/FONT]

Hope that is what you are looking for. :)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top