Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
Interrupt Driven SCI - "mr.mattyg" - Jun 4 14:48:22 2008
Hi Guys,
So I'm trying to set up a Serial Communication Interface between two
uC. I only have one test board with a uC, so I'm independently
setting up the Transmit and the Receive and testing the communication
using the hyperterminal from my computer. Essentially, one board
needs to transmit only, and the other needs to receive only.
Right now my problem lies in the Transmitting. I've set it up so that
my program enables TIE interrupts when I've sent data to the transmit
buffer (set up as a FIFO Ring Buffer). Once in the Interrupt I load
new data from the transmit buffer to the SCI Data Register if the TDRE
contains a '1'. In the interrupt I disable TIE only once my transmit
buffer is empty.
If I only load the transmit buffer with three or less bytes of data,
the SCI works fine and I see that data in the hyperterminal of the
computer. If I try more, the first three are transmitted fine, but
the remaining produce garbage on the hyperterminal screen, and
normally my uC freezes up. This is the problem. However If I add a
delay at the end of each byte transfer, then I have no problems
sending multiple bytes of data.
In the end, speed isn't a major concern of mine, so I can tolerate
having this delay, I'm just wondering if anyone has any ideas as to
why this is needed. My Baud Rate is set to 9600.
Thanks for any info, insight, etc...
Matt
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Re: Interrupt Driven SCI - Edward Karpicz - Jun 5 4:22:05 2008
Hello Matt,
> Hi Guys,
>
> So I'm trying to set up a Serial Communication Interface between two
> uC. I only have one test board with a uC, so I'm independently
> setting up the Transmit and the Receive and testing the communication
> using the hyperterminal from my computer. Essentially, one board
> needs to transmit only, and the other needs to receive only.
>
> Right now my problem lies in the Transmitting. I've set it up so that
> my program enables TIE interrupts when I've sent data to the transmit
> buffer (set up as a FIFO Ring Buffer). Once in the Interrupt I load
> new data from the transmit buffer to the SCI Data Register if the TDRE
> contains a '1'. In the interrupt I disable TIE only once my transmit
> buffer is empty.
Interrupt part sounds right, you write data after you read status register
(if TDRE is set). I guess you do the same for your first character, you read
status register, then write data?
>
> If I only load the transmit buffer with three or less bytes of data,
> the SCI works fine and I see that data in the hyperterminal of the
> computer. If I try more, the first three are transmitted fine, but
> the remaining produce garbage on the hyperterminal screen, and
> normally my uC freezes up. This is the problem. However If I add a
Sounds like baudrate mismatch. More back to back characters you send - more
baudrate mismatch is important.
> delay at the end of each byte transfer, then I have no problems
> sending multiple bytes of data.
Delay after char helps resynchronizing, even and especially if you have big
baudrate mismatch. Are you sure your micro sends really at or very close to
9600bps?
Regards
Edward
>
> In the end, speed isn't a major concern of mine, so I can tolerate
> having this delay, I'm just wondering if anyone has any ideas as to
> why this is needed. My Baud Rate is set to 9600.
>
> Thanks for any info, insight, etc...
> Matt
> ------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Re: Interrupt Driven SCI - Matt Gauthier - Jun 5 9:25:11 2008
Edward,
Thanks for the response. In calculating the Baud Rate, the SCI Block
Description PDF talks about the SCI Module Clock. I can't seem to find
anywhere in any of the data sheets how to set this. Is there a prescale off
the bus clock for this? Or is it simply the Bus clock? I used the Bus
clock (2MHz) in my calculation of the SCI Baud Rate. However, the only
other thing I could think of is, does the SCI Module clock run off the
Enhanced Timer Clock? Because I have that prescaled for my application.
Thanks,
Matt
> It's Now
Personal
Guides, news,
>
> advice & more.
> Best of Y! Groups
>
> Discover
groups
that are the best
>
> of their class.
> .
>
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Interrupt Driven SCI - Edward Karpicz - Jun 5 10:04:10 2008
SCI module clock is busclock only. If you have 2MHz busclock, then the most
close integer baudrate register setting should be 2MHz/16/9600 = 13. And
baudrate error ((2MHz / 16 / 13) - 9600)/9600 = 0.16%.
But that's provided your busclock is really 2MHz. The best you could do now
is checking the shortest bit time on Tx pin with the scope.
Edward
----- Original Message -----
From: "Matt Gauthier"
To: <6...@yahoogroups.com>
Sent: Thursday, June 05, 2008 4:25 PM
Subject: Re: [68HC12] Interrupt Driven SCI
> Edward,
> Thanks for the response. In calculating the Baud Rate, the SCI Block
> Description PDF talks about the SCI Module Clock. I can't seem to find
> anywhere in any of the data sheets how to set this. Is there a prescale
> off
> the bus clock for this? Or is it simply the Bus clock? I used the Bus
> clock (2MHz) in my calculation of the SCI Baud Rate. However, the only
> other thing I could think of is, does the SCI Module clock run off the
> Enhanced Timer Clock? Because I have that prescaled for my application.
>
> Thanks,
> Matt
>
>> It's Now
>>
Personal
>>
>> Guides, news,
>>
>> advice & more.
>> Best of Y! Groups
>>
>> Discover
>>
groups
>>
>> that are the best
>>
>> of their class.
>> .
>>
> [Non-text portions of this message have been removed]
> ------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Interrupt Driven SCI - Matt Gauthier - Jun 5 10:49:51 2008
Edward,
Thanks. Yeah, I had it set at 13. And on scope one bit transfer is approx
100us which it should be. Actually the problem was something to do with my
FIFO buffer GET function, called from the Interrupt Service Routine. In
GET_FIFO I would get the data and store it in mem where Register X was
pointing to, but hadn't initialized where Reg X was pointing to. So it
would overwrite the data that Reg X was pointing to before the GET call. I
can see why this would lock up my program, but not really sure why the DELAY
helped fix it. Seems to be Functioning properly now though without DELAY
and Initializing Reg X to point to a good location. Instead of writing the
data to where Reg X points to, I just copy the GET_FIFO_PTR to Reg X
before incrementing the GET_FIFO_PTR.
Thanks for the help,
Matt
P.S. It's great that you're on this Discussion post. I work alone and have
no mentors to discuss these things with, so having you as an online mentor
is GREAT.
On Thu, Jun 5, 2008 at 10:03 AM, Edward Karpicz
wrote:
> SCI module clock is busclock only. If you have 2MHz busclock, then the
> most
> close integer baudrate register setting should be 2MHz/16/9600 = 13. And
> baudrate error ((2MHz / 16 / 13) - 9600)/9600 = 0.16%.
> But that's provided your busclock is really 2MHz. The best you could do now
>
> is checking the shortest bit time on Tx pin with the scope.
>
> Edward
>
> ----- Original Message -----
> From: "Matt Gauthier" >
> To: <6...@yahoogroups.com <68HC12%40yahoogroups.com>>
> Sent: Thursday, June 05, 2008 4:25 PM
> Subject: Re: [68HC12] Interrupt Driven SCI
>
> > Edward,
> > Thanks for the response. In calculating the Baud Rate, the SCI Block
> > Description PDF talks about the SCI Module Clock. I can't seem to find
> > anywhere in any of the data sheets how to set this. Is there a prescale
> > off
> > the bus clock for this? Or is it simply the Bus clock? I used the Bus
> > clock (2MHz) in my calculation of the SCI Baud Rate. However, the only
> > other thing I could think of is, does the SCI Module clock run off the
> > Enhanced Timer Clock? Because I have that prescaled for my application.
> >
> > Thanks,
> > Matt
> >
> >> It's Now
> >> Personal<
>
http://us.ard.yahoo.com/SIG=13oq5hngr/M=493064.12016257.12445664.8674578/D=groups/S=1706554205:NC/Y=YAHOO/EXP=1212661322/L=/B=uOxOANFJq1w-/J=1212654122563113/A=4507179/R=0/SIG=12de4rskk/*http://us.rd.yahoo.com/evt=50284/*http://finance.yahoo.com/personal-finance
> >
> >>
> >> Guides, news,
> >>
> >> advice & more.
> >> Best of Y! Groups
> >>
> >> Discover
> >> groups<
>
http://us.ard.yahoo.com/SIG=13o2a2tf7/M=493064.12016306.12445698.8674578/D=groups/S=1706554205:NC/Y=YAHOO/EXP=1212661322/L=/B=uexOANFJq1w-/J=1212654122563113/A=4763762/R=0/SIG=11ou7otip/*http://advision.webevents.yahoo.com/bestofyahoogroups/
> >
> >>
> >> that are the best
> >>
> >> of their class.
> >> .
> >>
> >>
> >>
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> > ------------------------------------
> >
> >

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )