Re: Setting MPC555 SCI for 7 Bits 2 Stop Bits and Odd parity
"blogsyndrome" <[email protected]> Thu, 17 May 2007 04:37:17 -0000
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers |
|---|---|
| Message-ID | <[email protected]> |
I just finished reading the manual for what i needed the sci to
function as. Its not exactly what you need but may help you get on
the right track.
pg 513 has a table you might need to look at. though
heres how i setup the control registers:
open up hypertrm
Easy Settings: 9600, 8 data bits, no parity, 1 start and stop bit,
flow control none.
void setup_qsmcm()
{
QSMCM.QSMCR.B.STOP = 0;
// do I ignore the IMB3 freeze signal?
if(DEPLOYMENT_MODE == debug)
QSMCM.QSMCR.B.FRZ1 = 1; // yes
else
QSMCM.QSMCR.B.FRZ1 = 0; // no
QSMCM.QSMCR.B.SUPV = 0;
//keep registers access as global not restricted
//Setup Interrupt Pins
QSMCM.QDSCI_IL.B.ILDSCI = 5; //
define SCIIRQ at level 5
QSMCM.SCC1R1.B.TIE = 0;
// disable transmit interrupt;
QSMCM.SCC1R1.B.TCIE = 0;
// disable transmit complete interrupt;
QSMCM.SCC1R1.B.RIE = 1;
// enable receiver interrupt;
QSMCM.SCC1R1.B.ILIE = 0;
// disable idle-line interrupt;
//Before changing register values, allow the SCI to complete
the current transfer,
//then disable the receiver and transmitter.
QSMCM.SCC1R0.B.SC1BR = 0b0000010000010; // Set 9600
Baud 40000000/32/9600;
//SCI Control Register
QSMCM.SCC1R1.B.LOOPS = 0;
QSMCM.SCC1R1.B.WOMS = 0;
// normal CMOS output [only when configured as output txd]
QSMCM.SCC1R1.B.ILT = 0;
// idle-line; 0=short; 1=long
QSMCM.SCC1R1.B.PT = 0;
// 0 = even; 1 = odd
QSMCM.SCC1R1.B.PE = 0;
// parity disabled
QSMCM.SCC1R1.B.M = 0;
// mode select: 0 = 10 bit mode; 1 = 11 bit mode
QSMCM.SCC1R1.B.WAKE = 0;
// wakup by address mark; 0 = idle line detection; 1 =
address mark (last bit set)
QSMCM.SCC1R1.B.RWU = 0;
// normal receiver operation (received data recognized); 1 =
wakeup mode enabled (ignore data until awakened)
QSMCM.SCC1R1.B.SBK = 0;
// send break 0=normal; 1 = break frame(s)
QSMCM.SC1DR.R = 0x00;
// intialize first char to transmit, aka, null
QSMCM.SCC1R1.B.TE = 1;
// Enable Transmitter
QSMCM.SCC1R1.B.RE = 1;
// Enable Reciever
QSMCM.SCC2R0.B.SC2BR = 0;
// disable baud rate generator for sci2
QSMCM.SCC2R1.B.LOOPS = 0;
QSMCM.SCC2R1.B.WOMS = 0;
QSMCM.SCC2R1.B.ILT = 0;
QSMCM.SCC2R1.B.PT = 0;
QSMCM.SCC2R1.B.PE = 0;
QSMCM.SCC2R1.B.M = 0;
QSMCM.SCC2R1.B.WAKE = 0;
QSMCM.SCC2R1.B.TIE = 0;
QSMCM.SCC2R1.B.TCIE = 0;
QSMCM.SCC2R1.B.RIE = 0;
QSMCM.SCC2R1.B.ILIE = 0;
QSMCM.SCC2R1.B.RWU = 0;
QSMCM.SCC2R1.B.SBK = 0;
QSMCM.SCC2R1.B.TE = 0;
QSMCM.SCC2R1.B.RE = 0;
}
//using status registers for transmit and receive
void send_char(char c)
{
INTERRUPTS_DISABLE
// while(QSMCM.SC1SR.B.TDRE != 1 && QSMCM.SC1SR.B.TC != 1);
while(QSMCM.SC1SR.B.TDRE != 1);
// wait till data in data register has been
moved to serial shifter
// (TDRE = transmit data register empty =
read only)
QSMCM.SC1DR.R = c; // Move/Write Data to Transmit Register
while(QSMCM.SC1SR.B.TC != 1);
// data transfer of char is complete
// (TC = transfer complete).
INTERRUPTS_ENABLE
}
my send function works when its flashed.. although i get a weird 1
char added on first use of my send_char
http://people.tamu.edu/~leblanc/forums/sci/sci_transmit_problem_initia
l_char.jpg