Jump to content
Sign in to follow this  
Ossah

16f628 And Usart Programming Boostc

Recommended Posts

Hi all,

 

I am using BoostC to program a small project I am building using a Pic16F628.

I am hoping to use the hardware USART of one PIC to transmit a byte of data to another PIC using wireless modules attached to each PIC USART port.

 

I only need 1 way comms between one transmitter pic and one receiver pic.

 

I am a little lost as to how to use the USART. I have looked at the rs232_driver.h file and am still a little lost.

I understand about the different registers that need to be setup such as SPBRG and TXSTA, RXSTA etc and understand how to program it in assembly but I am unsure about how to do it in

BoostC.

 

Can anyone give me any pointers as to how to setup a simple program that sends data via USART and one that receives data using USART.

 

Any help would be much appreciated.

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

They are many ways to do it.

One i use, for instance to receive is by interrupt.

 

if( pir1.RCIF )		// USART interrupt - requires enable uart interrupt bit
{
rxbuffer = rcreg;		   // Recebe sempre dados
}

 

Whenever anything arrives RCREG is saved to rxbuffer (unsigned char).

 

Now, to send something, just do:

 

if( txsta.TRMT )	// I use "if" because this is inside of a machine state
{
txreg = txbuffer;
}

 

Of course, before use it you have to configure uart first.

 

Later we can continue with this.

 

Regards,

joli

Share this post


Link to post
Share on other sites
...I am a little lost as to how to use the USART. I have looked at the rs232_driver.h file and am still a little lost.

I understand about the different registers that need to be setup such as SPBRG and TXSTA, RXSTA etc and understand how to program it in assembly but I am unsure about how to do it in

BoostC.

 

Can anyone give me any pointers as to how to setup a simple program that sends data via USART and one that receives data using USART...

 

Here is a link to UART driver that will replace existing rs232_driver. And here is a link to another sample code that uses same UART driver. Very easy to use (API consists of only 5 calls) especially if you need just one UART.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...