DELETED
Loopback WHAT?
Ray, this one Loopback Test
There's virtually nothing to "implement". Jumper Rx to Tx, write a few lines of code to send data to Serial, and a few more lines to read what's received. They should be identical.
Regards,
Ray L.
Did anybody successfully implemented local loopback test on Due in software?
This could be called a loopback, but I don't understand why you would want to do this or why it's in the Due section...
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()) Serial.write(Serial.read()));
}
In all honesty - it is none of your business why I want to do this.
I don't mean to be rude, I am just frustrated by several posts in row indicating that the OP was not read.
And the reason it is in Due forum because the processor has several test modes implemented in hardware as I indirectly indicated in my OP.
I , perhaps naively, expected that someone who knows about this subject from my description and from experience will answer, not just receiving bunch of inquiries indicating that the OP was not read.
I am not in a position to explain what , why, how etc. loopback is about.
I am truly sorry for unloading on you, but I value my time and this so far has been total waste.
Please accept my sincere apology.
Vaclav
Ps991:
Ray, this one Loopback Test
NOPE
Just set the channel mode in the UART mode register.
Some simple bit arithmetic.
It's not rocket surgery.
Your original post was about as clear as mud! You made NO mention of Serial! For all we know, you wanted to loopback the I2S, or SPI, or USB or any of several other interfaces. You shouldn't expect us to be mind-readers. Make a CLEAR post, giving enough information for others to understand what you're asking without having to guess. You got no helpful responses because you didn't pose a clear question, and then you got impatient.
Regards,
Ray L.
It seems to me this is all you need to know and modify
void UARTClass::begin(const uint32_t dwBaudRate, const UARTModes config)
{
uint32_t modeReg = static_cast<uint32_t>(config) & 0x00000E00;
init(dwBaudRate, modeReg | UART_MR_CHMODE_NORMAL);
}
void UARTClass::init(const uint32_t dwBaudRate, const uint32_t modeReg)
{
// Configure PMC
pmc_enable_periph_clk( _dwId );
// Disable PDC channel
_pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
// Reset and disable receiver and transmitter
_pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS;
// Configure mode
_pUart->UART_MR = modeReg;
// Configure baudrate (asynchronous, no oversampling)
_pUart->UART_BRGR = (SystemCoreClock / dwBaudRate) >> 4;
// Configure interrupts
_pUart->UART_IDR = 0xFFFFFFFF;
_pUart->UART_IER = UART_IER_RXRDY | UART_IER_OVRE | UART_IER_FRAME;
// Enable UART interrupt in NVIC
NVIC_EnableIRQ(_dwIrq);
// Make sure both ring buffers are initialized back to empty.
_rx_buffer->_iHead = _rx_buffer->_iTail = 0;
_tx_buffer->_iHead = _tx_buffer->_iTail = 0;
// Enable receiver and transmitter
_pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
}
#define UART_MR_CHMODE_LOCAL_LOOPBACK (0x2u << 14) /**< \brief (UART_MR) Local Loopback */
Instead of "I have some notes on the subject," what about:
- Here's a link to a similar project someone else did.
- Here's what I don't understand about it.
- Here's a datasheet - please check my understanding of page 397
- Here's the code I tried.
- Here's the actual output it gave.
- Here's the description of what I expected/wanted it to do.
- Here's a schematic of how I wired it up.
- Here's a photo of my actual wiring, with all of the breadboard connections clearly visible.
- Here's some information about the external system which might possibly be useful to someone answering the question, even though I don't think it's relevant (voltage, power, serial data communications, distance from wireless receiver and why I thought that item #1 might be a solution to my real problem.)
That's what I call "notes."
I found my Due!
void setup()
{
Serial.begin (115200);
Serial1.begin (115200, static_cast<UARTClass::UARTModes>((uint32_t)SERIAL_8S1 | UART_MR_CHMODE_LOCAL_LOOPBACK));
Serial.println ("Ready");
Serial1.print ("Foxtrot Oscar");
}
void loop()
{
if (Serial1.available ())
{
Serial.print ("Received <");
Serial.print ((char)Serial1.read ());
Serial.println (">");
}
}
(Did you see what I did there with [code][/code] tags?)
(No app notes were read or harmed in the making of this post)
It works! I still don't know why you might want to do this, but it's good to know a bit more about the registers. I'll save that one in my library for future use.
MorganS:
It works! I still don't know why you might want to do this
Vaclav's told us it's none of our business, so I guess we'll never know.
OTOH, s/he claims s/he never reads my posts, so s/he'll just have to reinvent this particular wheel.
Vaclav:
DELETED
Oh dear.
Not good, Vaclav.
Really, really not good.