Other Parts Discussed in Thread: TMS320F2812
Hi all,
Im relatively new to the dsp environment. Im using the eZdsp TMS320F2812 from spectrum digital and using CCSv4 to compile my project.
I finally able to use the interrupt for receving and tranmistting - i have tested it using simple algorithm. But in project I am doing a lot of numbers computational, and need to output them to the serial port. Using the same algorithm, for some reason Im getting a different output at my hyperterminal.
I'll explain further below.
I just print a simple array of characters to test the interrupt.
char message1[]={"F2812 - read2 !\n\r"};
and main is as below:
while(1) {
ScibRegs.SCITXBUF=message1[index++]; //if no interrupt happens, sending message1 to the transmit
counter = strlen(message1); //find the length of message1 so that transmitter know the exact size of it
while (i<30000) { //Delay loop for every the message1
i++; //Increment i while it is in idle state
//printf("%d\n", i);
if(j==1) { //if interrupt happens, go to idle state
while(1){ //in idle state, keep waiting for incoming messages
if (k==1) { //if statement given an EOF reach
k=0; //set the flag of EOF reached and continue transmitting
break;
}
}
}
}
i=0;
}
and my transmit interrupt function
interrupt void SCI_B_TX_isr(void)
{
if (counter1 == 1) {
if (index < (counter+1)) ScibRegs.SCITXBUF=send[index++];
else {index=0;counter1=0;}
}
else {
if (index < (counter+1)) ScibRegs.SCITXBUF=message1[index++];
else index=0;
}
// Reinitialize the PIE for next SCI-A TX-Interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Acknowledge interrupt to PIE
return;
}
so the basic overview is, keep printing message1 to the serial while there is no receive interrupt. If there an interrupt at receiver, go to the while(1) and keep waiting until EOF reached - EOF is denoted with K==0 hence its breaking out of the loop. Once it broke off the while(1), the program will continue printing message1. The transmit function will always go to the else{} given that there is interrupt received; if receive interrupt happen, it will go to if(counter==1){} to print whatever character is received.
and that worked fine.. i get the character as I wanted, and i got what i expect on my hyperterminal.
eg.
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
F2812 - read2 !
But if i port this entire code, and make adjustment to my project, the output of message1 will start look funny; it doesn't print the whole character, sometimes its missing some characters, and quite often doesnt print out the \r\n.
below is what shown in my hyperterminal after I integrate the code to my project:
F2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - read2F2812 - readF2812 - read2F2812 - readF2812 - read2F2812 - readF2812 - read2F2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - reaF2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - readF2812 - reaF2812 - readF2812 - readF2812 - readF2812 - read2F2812 - readF2812 - readF2812 - readF2812 - read2 !
F2812 - readF2812 - read2F2812 - read2 F2812 - readF2812 - read2F2812 - read2F2812 - readF2812 - readF2812 - readF2812 - read2F2812 - read2 F2812 - read2F2812 - read2F2812 - readF2812 - read2F2812 - read2F2812 - read2F2812 - read2 F2812 - read2F2812 - read2F2812 - readF2812 - readF2812 - read2 F2812 - read2F2812 - read2 F2812 - read2 F2812 - read2 F2812 - read2 F2812 - read2F2812 - readF2812 - read2 !F2812 - readF2812 - readF2812 - read2F2812 - read2F2812 - readF2812 - readF2812 - read2F2812 - read2 !
comparatively speaking, it is nearly constantly mising the "!", "\r", "\n". but both have exactly the same setting.
if I run my trial code before my while loop, it worked fine, but once i remove the trial code and let my loop to do printing, it messed up.
If I modifiy the interrupt transmit code to be below
interrupt void SCI_B_TX_isr(void)
{
if (counter1 == 1) {
if (index < (counter+1)) ScibRegs.SCITXBUF=send[index++];
else {index=0;counter1=0;}
}
else {
if (index < (17) ScibRegs.SCITXBUF=message1[index++];
else index=0;
}
// Reinitialize the PIE for next SCI-A TX-Interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Acknowledge interrupt to PIE
return;
}
where 17 is the string length, it prints out fine and works fine. but it is not possible to have a fix constant in my if statement such as 17 because my string length will always change depending on the floating number generated( this floating number got converted to string at the end).
Anyone has ever experience in this?
Any help will greatly appreciated - i've stuck with this for more than 1 week and still couldnt figure it out.
I really2 appreciate everyones help.
Thank you very much.
Kind regards,
Sucahyo