Problem using UART to transmit messages to an LCD
hello,
using the 'initUART.asm' and 'xmitmsg.asm' - files from the uart echo back - project on my adsp21369 ez-kit lite simply to put out a message to a serial lc-display.
the transmission of the welcome-message works perfectly well. but if i call the function "xmitmsg" from another point in my programm (in my case from an ISR called "talkthroughISR") i just get the "||" sign for every char! so, for example, if i want to transmit the string "test" as a welcome message, my display shows "test". if i call the same function "xmitmsg" from an ISR, the display shows "|| || || ||".
"||" seems to be the ascii-equivalent to the "0"char, so if i send a "0" as welcome-message, i get this sign too. the determination of the bufferlength seems to work, because i get one "||"-sign for every char, but the buffer seems to be initialized with zeros, and i don't know why. i went through the whole programm setting breakpoints, the the r0 register holds the right adress. here's the code:
UARTinit.asm:
#include <def21369.h>
.global _initUART;
.extern _xmitmsg;
.section/dm seg_dmda;
.var message_on[] = {254, 1, 'ON'};
.var welcome_message[] = {254, 1, 254, 128, 'BOOT'};
.global welcome_message;
.global message_on;
.section/pm seg_pmco;
_initUART:
/* Sets the Baud rate for UART0 */
ustat1= UARTDLAB;
dm(UART0LCR) = ustat1; //enables access to Divisor register to set baud rate for UART0
r0=0x38; dm(UART0DLL) = r0;
r0=0x4; dm(UART0DLH) = r0; //0x438 = 1080 for divisor value and gives a baud rate of 9600 at 331.776Mhz core clock
/* Configures the UART LCR */
ustat1 = UARTWLS8; // word length 8
dm(UART0LCR) = ustat1; // sets UART0 Line with one stop bit, no parity and with baud rate of 9600
ustat1 = UARTEN;
dm(UART0TXCTL) = ustat1; // enable UART0 transmitter
r0 = welcome_message;
r1 = length(welcome_message);
call _xmitmsg; // function to transmit welcome message, works perfectly well
_initUART.end:
rts;
talkthroughISR.asm:
#include <def21369.h>
#include "srunewlx3.h"
.section /pm seg_pmco;
.global _talkThroughISR;
.extern handle_MISCA1;
.extern _xmitmsg;
.extern welcome_message;
.extern message_on;
_talkThroughISR:
if FLAG0_IN jump _on;
if NOT FLAG0_IN jump _off;
_ein:
r0 = message_on;
r1 = length(message_on);
call _xmitmsg; //call from an ISR, doesn't work at all!!!
.
.
.
hope u can tell me, why it doesn't put out the message "ON" like defined in the initialization but "|| || || ||"
thx in advance,
Tschem
Hi Tschem,
I will get back to you once i go through your code.
Thanks
Deepa
Hi Tschem,
I tried implementing what you had mentioned and i am able to see the message getting displayed witohut issues.
I have attached the project. Please check that out and let me know it that works for you.
Thanks
Deepa
hello DeepV,
i don't know why, but it works pefectly! my code is more or less the same, but doesn't. i was searching for about 4 hours for a difference in code but couldn't find anything. nonetheless, thx very much!
one last question: in your 'initSPORT' file u've choosen i2s mode (like me), but in the 'SPORTisr' file you made the following:
r10=dm(RXSP0A); // Read new left sample from ADC
dm(TXSP1A)=r10; // Write to DAC1
dm(TXSP1B)=r10; // Write to DAC2
dm(TXSP2A)=r10; // Write to DAC3
dm(TXSP2B)=r10; // Write to DAC4
...so u just read the left sample...looks like mono-operation, but works perfectly well in stereo! how is it possible to make the codec work in mono operation?
my code (makes more sense for stereo, but sounds exactly the same like yours):
r10=dm(RXSP0A); // Read new right sample from ADC
r9=dm(RXSP0A); // Read new left sample from ADC
dm(TXSP1A)=r10; // Write to DAC1
dm(TXSP1A)=r9;
dm(TXSP1B)=r10; // Write to DAC2
dm(TXSP1B)=r9;
dm(TXSP2A)=r10; // Write to DAC3
dm(TXSP2A)=r9;
dm(TXSP2B)=r10; // Write right sample to DAC4 (HeadPhone)
dm(TXSP2B)=r9; // Write left sample to DAC4 (HeadPhone)
thx, tschem.
Hi Tschem,
Sorry about the delay in response. In the sample based talkthrough, an interrupt occurs everytime a 32 bit word is shifted in. In I2S mode, there are two channels per frame and two interrupts occur for each. So though the comment in the code is a little misleading, by saying "left sample", it doesnt mean that only left channel is sampled. For one interrupt, left word is sampled and the other interrupt right word is sampled. So you get two interrupts per frame and the dsp receives two channels per frame. So it is still stereo.
Let me know if you still have questions.
Thanks
Deepa
everything clear now. thank you!
greets, Tschem
This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.
Thank you,
EZ Admin
Please log in to reply.