MC9S12 : SCI programming

could anyone point me to a source of ideas on how to use the SCI serial port in mc9s12 parts? on the freescale site i did find a description of a monitor program AN2548.PDF (which i suppose to rely on RS-232 comm's) but, though the assembly listing is said to be available, i failed to find it on the site or elsewhere in the www

does anyone know where to find AN2548SW1.ZIP? or can you point me to other examples of how to use SCI?

Thanks in advance, KA

PS how come there's so few discussions of these chips in this forum? are they little used? or very easy to program? well supported?

Reply to
karel
Loading thread data ...

=_NextPart_000_00A1_01C60FC9.1CDAEAF0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

You really should take the little time needed to do a web search. = Finding the files (there are two files for this AN) you need are readily = available on freescale.com. Just use AN2548 in its search engine:

formatting link

Reply to
Gary Schnabl

"Gary Schnabl" schreef in bericht news: snipped-for-privacy@comcast.com...

You really should take the little time needed to do a web search. Finding the files (there are two files for this AN) you need are readily available on freescale.com. Just use AN2548 in its search engine:

formatting link

Well I know I shouldn't be lazy... I had done some web searching, also on the freescale site, before posting my request. At your instigation I renewed these efforts, but found nothing more than in my first efforts. Best I found were links that required registration, which I found strange and not worth the effort, given there's no guarantee there's anything useable behind.

I had really trusted there would be more and better accessible support and help for these chips - ok, I'll have to change my mind.

Disappointed, KA

Reply to
karel

KA

I did my own driver for this chip a few months ago. I hacked together something that works quite good.

I'm using the 9S12DG128A. With 2 serial channels. I took days to look for a bug. I found it in the PRM file. I defined the wrong serial channel for my test. Here is some code that works. the imediate below is in the PRM file.

VECTOR ADDRESS 0xFFD6 sci0_isr /* 0xFFD6 SCI * VECTOR ADDRESS 0xFFD4 sci1_isr /* 0xFFD6 SCI */

sci0_isr responds to the interupt handler.

And don't forget to make it a normal segmant after.

Here is some c code that works for the MC9S12128B variant.

/* SCI0*/ #pragma CODE_SEG NON_BANKED interrupt void sci0_isr(void) { SCI0InterruptHandler(); } #pragma CODE_SEG DEFAULT

void SCI0InterruptHandler(void) { U_BYTE dummyData; /* Clear Flag*/

//PORTA ^= LED_MASK_B; if (SCI0SR1 & (RDRF + OR)) { // clear the interrupt flag by reading the status register and // then the data register dummyData = SCI0SR1; dummyData = SCI0DRL; ProcessSCI0Byte(dummyData); //ReceiveMessage(SCI0DRL); /* this should auto clear flag*/

} if ((SCI0CR2 & TIE) && (SCI0SR1 & TDRE)) { // clear the interrupt flag by reading the status register dummyData = SCI0SR1; // check if there are more bytes to send if (txBufferIndexSCI0 < txBufferLengthSCI0) { // there are more bytes SCI0DRL = txBufferSCI0[txBufferIndexSCI0++]; } else { // turn off transmit empty interrupt SCI0CR2 &= ~SCICR2_TIE; } }

Reply to
Malt

=_NextPart_000_0091_01C61308.D448E150 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Registering through the freescale.com site is a no-brainer, one-time = effort and only requires a few minutes - probably much less effort than = your posting on the Usenet.=20

As I said before, there are two (both zipped) parts for the software for = that AN. I downloaded both parts, just to see how easy it was to do.

Reply to
Gary Schnabl

... snip ...

I suspect Karels point is that he objects to the privacy implications of registering at some fairly anonymous site.

--
"If you want to post a followup via groups.google.com, don't use
  the broken "Reply" link at the bottom of the article.  Click on
  "show options" at the top of the article, then click on the
  "Reply" at the bottom of the article headers." - Keith Thompson
More details at:
Reply to
Chuck F.

"Malt" schreef in bericht news: snipped-for-privacy@g44g2000cwa.googlegroups.com...

Thank you Sir! Unfortunately I'm doing it all in assembler so this C code is not much use to me except to gather ideas from... While we're at it, could you explain to me the exact meaning of the #pragma clauses? (in wording that a poor assembly programmer might understand....)

KA

Reply to
karel

No not really. My objection is that I found the website to be in a kind of permanent reorganisation, I came upon several dead links. So I was afraid the registration would turn out to be a waste of effort. If it is indeed such a simple thing I might well take the risk...

But meanwhile I did find a good deal of stuff to work on: I've got the complete register description "S12SCI block description" that's enough to keep me occupied for a good while.

Thanks for thinking along! PS I keep wondering why these chips are so little discussed here, are they not frequently used? Or do they have a forum dedicated to them?

KA

Reply to
karel

There are some dedicated Freescale forums - independent from FSL - on Yahoo groups for the HC05/08, HC(S)12, HC11. They are all active. In addition, FSL has their Embedded Learning Center which covers their entire line. And then there's the VirtuaLabs through TechOnline for web-based simulators of selected MCUs - MC9S08QG8, NE64? for the HCS12, etc.

Reply to
Gary Schnabl

KA To my very limited understanding #PRAGMA is used in C to tell the compiler some condition which is not default. I can't tell you anything else. Except I've seen '#pragma asm' in c code to simpilfy expersions which are easier in asm then c.

Regards Malt

Reply to
Malt

Malt wrote: >

The following quote from N869 (draft C standard) is all you know about pragma. The update to this is N1124. Note that pragma is in lower case. Use of pragma seriously harms portability.

6.10.6 Pragma directive

Semantics

[#1] A preprocessing directive of the form

# pragma pp-tokens-opt new-line

where the preprocessing token STDC does not immediately follow pragma in the directive (prior to any macro replacement)136) causes the implementation to behave in an implementation-defined manner. The behavior might cause translation to fail or cause the translator or the resulting program to behave in a non-conforming manner. Any such pragma that is not recognized by the implementation is ignored.

____________________

136An implementation is not required to perform macro replacement in pragmas, but it is permitted except for in standard pragmas (where STDC immediately follows pragma). If the result of macro replacement in a non-standard pragma has the same form as a standard pragma, the behavior is still implementation-defined; an implementation is permitted to behave as if it were the standard pragma, but is not required to.

[#2] If the preprocessing token STDC does immediately follow pragma in the directive (prior to any macro replacement), then no macro replacement is performed on the directive, and the directive shall have one of the following forms whose meanings are described elsewhere:

#pragma STDC FP_CONTRACT on-off-switch #pragma STDC FENV_ACCESS on-off-switch #pragma STDC CX_LIMITED_RANGE on-off-switch

on-off-switch: one of ON OFF DEFAULT

Forward references: the FP_CONTRACT pragma (7.12.2), the FENV_ACCESS pragma (7.6.1), the CX_LIMITED_RANGE pragma (7.3.4).

--
"If you want to post a followup via groups.google.com, don't use
  the broken "Reply" link at the bottom of the article.  Click on
  "show options" at the top of the article, then click on the
  "Reply" at the bottom of the article headers." - Keith Thompson
More details at:
Reply to
Chuck F.

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.