fixed usart to not wait two bytes before triggering txready

git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@313 23d1a52b-0c3c-0410-b72d-8f29ab48fe35
This commit is contained in:
joxe 2008-09-10 13:38:45 +00:00
parent e03a314fdd
commit a47e4e9bc2
3 changed files with 17 additions and 5 deletions

View File

@ -266,12 +266,14 @@ public class USART extends IOUnit {
}
if (clockSource == MSP430Constants.CLK_ACLK) {
if (DEBUG) {
System.out.println(getName() + " Baud rate is: " + cpu.aclkFrq / div);
System.out.println(getName() + " Baud rate is (bps): " + cpu.aclkFrq / div +
" div = " + div);
}
baudRate = cpu.aclkFrq / div;
} else {
if (DEBUG) {
System.out.println(getName() + " Baud rate is: " + cpu.smclkFrq / div);
if (DEBUG) {
System.out.println(getName() + " Baud rate is (bps): " + cpu.smclkFrq / div +
" div = " + div);
}
baudRate = cpu.smclkFrq / div;
}
@ -298,7 +300,7 @@ public class USART extends IOUnit {
// This should be used to delay the output of the USART down to the
// baudrate!
public long ioTick(long cycles) {
if (nextTXReady != -1 && cycles > nextTXReady) {
if (nextTXReady != -1 && cycles >= nextTXReady) {
// Ready to transmit new byte!
setBitIFG(utxifg);

View File

@ -248,7 +248,6 @@ public class ESBGui extends JComponent implements KeyListener,
}
public void keyPressed(KeyEvent key) {
// System.out.println("Key Pressed: " + key.getKeyChar());
if (key.getKeyChar() == 'd') {
node.setDebug(!node.getDebug());
}

View File

@ -284,6 +284,8 @@ static void testUSART() {
static void testTimer() {
int i;
unsigned int time;
int result;
pos = 0;
dint();
/* Select SMCLK (2.4576MHz), clear TAR; This makes the rtimer count
@ -316,6 +318,15 @@ static void testTimer() {
printf("Trigg time %d => %u\n", i + 1, times[i]);
assertTrue(times[i] >= t && times[i] < t + 2);
}
printf("Start modulo\n",time = TBR);
result = 47;
for (i = 0; i < 1000; i++) {
result = result + i % 27;
}
printf("Elapsed %i %i\n",TBR - time, result);
}
/*--------------------------------------------------------------------------*/