Problem related to SCI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem related to SCI

2,551 Views
saurav
Contributor I
Hi All,

I am facing a problem with the SCI in MC9S12XDT256. I am using CodeWarrior 5.7.0 with P&E Multilink Cyclone Pro for the development. I am using iSYSTEM iC3000HS Emulator for debugging.

I want to set up one of the SCI modules (say, SCI0) as a transmitter only. I have an array with 'n' bytes (say, 20) which have to be transferred out via the SCI. I do not want to receive anything through the SCI. My data format is: 1-8-1, no parity, 9.6k baud. I think that I'm configuring the SCI correctly. But not able to handle the interrupts correctly. While initializing the SCI, I have enabled TE & rest of the pins are set to 0 in SCI0CR2.

To send out the data, I fill up the queue & enable SCI0CR2_SCTIE. This generates the SCI interrupt. I wait for TDRE to become 0. Then I load SCI0DRL with a byte. However, I disable SCI0CR2_SCTIE (i.e., SCI0CR2_SCTIE = 0) after each load, till all the bytes are transferred.

When I observe the SCI registers during single-stepping, I see TDRE to be set etc. However I see no data on SCI0DRL and also the status register SCI0SR1 does not get cleared as it should (i.e., after I load SCI0DRL after reading SCI0SR1).

I am new to interrupt handling. Please help me out.

With warm regards,
Saurav
Labels (1)
0 Kudos
Reply
4 Replies

808 Views
Lundin
Senior Contributor IV
You just need to read some of the flags to clear them. This applies to the status registers in for example SCI and SPI. It is not a new feature, it has been like that since HC11.

Some other registers on the HC12, like for example the timer flags, you clear by writing 1 to them. Some flags you clear by writing 0. Some you clear by writing to other bits. And so on.

I mean, what's the fun in clearing every status register in the mcu in the same way? That would allow us to write generic, readable code and to use the debugger without automagical clearing of registers. Sounds boring to me.
0 Kudos
Reply

808 Views
saurav
Contributor I
Hi all,
Thanks for your replies. I was kind of able to solve it. I connected a PDA on the line & used the same code to send some data. I received everything properly. But I could not see those data on SCI0DRL. However, the interrupt bits were toggling as they should. I ended up expecting to see my data on SCI0DRL in the debugger, but could not see them.

Hi Nabla,
In HCS12X, just reading the mentioned register clears it. No need for explicit write.

With warm regards,
Saurav
0 Kudos
Reply

808 Views
Lundin
Senior Contributor IV
Sounds like an issue with the status flags. Perhaps your debugger is destroying those flags for you? If you have a memory map or similar active, the debugger will read from the status registers and mess up all flags.

(clearing flags by reading them ought to be the most stupid feature in the whole HC12)

If not, then please post the code.
0 Kudos
Reply

808 Views
Nabla69
Contributor V
Hello,
 
I believed to reset most of the flags on HC12 and S12 you not only needed the register to be read with the flag set.
But you also needed to write a 1 to that same flag.
 
Has it changed in new products ?
 
Roberta.
0 Kudos
Reply