Timer Interrupt and software UART

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Timer Interrupt and software UART

Postby Sytan » Wed Dec 08, 2010 6:34 pm

Hi all,

My PIC serves USB with timer2 interrupt and at the same time i'm trying to implement some software UART communication on the same PIC. My question is, will my timer interrupt affect the software UART communication? FYI internal UART can works fine.

Regards
sy
Sytan
Apprentice
 
Posts: 33
Joined: Mon Jun 07, 2010 3:10 pm

Re: Timer Interrupt and software UART

Postby yonghui » Wed Dec 08, 2010 11:32 pm

hi,

if the process in the timer interrupt is taking too long time. if might affect the accuracy of the baud rate if u are using the looping delay for the uart.
mayb u can try timer interrupt also the the baud rate of the software uart.

regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Timer Interrupt and software UART

Postby zhenning » Wed Jan 05, 2011 12:05 am

depending on the PIC too. Faster PIC can do faster processing so it wont affect that much. what PIC you are using?
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: Timer Interrupt and software UART

Postby Sytan » Mon Jan 10, 2011 5:16 pm

Thank you guys,

Due to my peripheral hardware delay(waiting user input) i had chosen another alternative and the problem is now solved.Thanks :lol:
Sytan
Apprentice
 
Posts: 33
Joined: Mon Jun 07, 2010 3:10 pm

Re: Timer Interrupt and software UART

Postby shiyan » Mon Jan 10, 2011 10:28 pm

Sytan WROTE:Thank you guys,

Due to my peripheral hardware delay(waiting user input) i had chosen another alternative and the problem is now solved.Thanks :lol:


How and what is the alternative method, come and share with us.
User avatar
shiyan
Amateur
 
Posts: 189
Joined: Wed Jun 09, 2010 10:59 am

Re: Timer Interrupt and software UART

Postby Sytan » Tue Jan 11, 2011 10:30 pm

my peripheral will waiting for user input which definitely need time larger than the tolerance time for USB service before it replies time-out. So i use another lower cost 16F PIC to serve all 4 peripherals (4 pairs of uart in used) another 18F microcontroller used to get important info from 16F and send to USB port and vice versa. The cons is 1 more PIC in used in this project but all the event can be managed easily by using proper interrupts. I'll try to improve it to use only 1 PIC, any suggestion from you guys? 4 UART with bi-direction USB communication with peripherals that causing some delay.
Sytan
Apprentice
 
Posts: 33
Joined: Mon Jun 07, 2010 3:10 pm

Re: Timer Interrupt and software UART

Postby aurora » Tue Jan 11, 2011 11:07 pm

Wow... 4x UARTs..!!

How critical is your UARTs transmission? Are the data very important?

For my software UART, here is what I did:
1. write a single character (I use 0xFE, can be anything)
2. wait for string of character and save, and check for special acknowledge (single character, I use 0xFF, also can be anything)
3. Once the special acknowledge character is received, end the transmission

On the transmission end, I have RX interrupt enable. It will be doing whatever, and when it receive a character, an interrupt is called. Within the interrupt routine, I transmit my data, last character ends with 0xFF.

If your transmission end is not that critical, you can use the above example and get data from each UART one after another. After complete, transmit the data through USB to your host. Lastly, follow by whatever routine you wish to do.

Of course, this can only happen if you can sort of manipulate the transmission line, to start transmitting only after it receive a special character (0xFE, in my case) from the UART. By the way, it will limit the data transmission by a bit, since you cannot use the two special character in your transmission line. For my case, 0xFE (254) and 0xFF (255).
aurora
Discoverer
 
Posts: 126
Joined: Sun Jun 07, 2009 4:52 pm

Re: Timer Interrupt and software UART

Postby Sytan » Wed Jan 12, 2011 1:36 am

thanks aurora,i got your point. I'll try that out later.Need some time to revise my protocol to find the "special" character that probably won't appear in data string to appoint it to be the ending byte. Thanks for your suggestion :lol:
Sytan
Apprentice
 
Posts: 33
Joined: Mon Jun 07, 2010 3:10 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 6 guests

cron