!Hello everyone,
I have a board composed of a MK10DN512VLL10 connected via UART to a Fastrax UP501 GPS module.
Main:
#define STDIO_UART1
volatile bool contr_GPS = false;
volatile char GPS_buff[3000];
volatile int i=0;
#ifdef STDIO_UART1
// enable GPS connector to be used as external UART connection
PTC->PSOR = (1u << 1);
uart_enable(1, 9600, false, true);
printf("ready.\r\n");
#endif
for(;;)
{
if (contr_GPS) |
{
for (z=0; z<3000; z++) | |||
printf("%c", GPS_buff[z]); |
}
}
Interrupt management:
extern volatile char GPS_buff[];
volatile char *data=GPS_buff;
volatile bool contr_write = true;
extern volatile bool contr_GPS;
extern volatile int i;
static void process_irq(uint8_t dev) {
UART_Type *uart = uart_reg[dev];
//UART_Trans *buffer;
if (uart->S1 & UART_S1_TDRE_MASK) {
// NON C'E' NULLA PERCHE' TEORICAMENTE DOVREBBE DARE QUALCUSA DI DEFAULT
}
if (uart->S1 & UART_S1_RDRF_MASK) {
if (i<3000){
*data++ = uart->D;
i++;
}
else
{
uart->C2 &= ~UART_C2_RIE_MASK;
uart->C2 &= ~UART_C2_RE_MASK;
contr_GPS = true;
}
}
}
If I remove contr_GPS and random print stuff out but meaningless symbols. Example:
? Cm? T? À "6½UùÄ? UG0? ¾m8? ËWÞÑæ +> ?? W®ÝUâ? ‡, |ù? Õ [??,? ÞÓÙú
Hz? $: bQŸZø "Å × · §ºö? † Ñ ?? ߧĺ6Ë AU ÷ Á ¢,? - ¡° Ê ú- ^ J¤ † Æ ÷? OCHA? Aini ??? 7ØU¤½ü%? Œ \ ä¼0? ¢ ñ> ݺ-ù9Tê? Æ? Y ÷ ü £
If you leave the condition contr_GPS prints nothing.
Do you have any tips or suggestions to understand or correct the mistake?
Thank you
Hi nikivendola
RDRF is a flag that is set to indicate that Receive Data Register is Full. But you need to clear it so it can be set again in other interrupt. To clear RDRF, read S1 when RDRF is set and then read D.
if (uart->S1 & UART_S1_RDRF_MASK)
{
if (i<3000){
/* Dummy read for S1 when RDRF bit is set */
(void)uart->S1;
/* Read received character, RDRF will be cleared */ *data++ = uart->D; i++; }
else { uart->C2 &= ~UART_C2_RIE_MASK; uart->C2 &= ~UART_C2_RE_MASK; contr_GPS = true; }
}
Also, I don't see clear where and how your Process_irq function is called? This also could be related.
Hope this information can help you.
Best Regards
Jorge Alcala
Thanks for your answer
I wanted to ask one more thing. I added a breakpoint but I can not take it off. At each Debug I remove him with the double click on the breakpoint or double X but to debug later reappears.
How can I do?
Thank you and greetings
Hi nikivendola
What debug interface are you using? and How this breakpoint appear in your breakpoint list? (windows>show views>Breakpoints). Could you please check the disassembly view and verify if the breakpoint appear there.
Best Regards
Jorge Alcala
This is useful for you?
Hi nikivendola
You're using segger j-link to debug. The Breakpoint that you showed in your image is set in the startup menu configuration. You can uncheck this breakpoint in the startup tab in the debug configuration:
You can also check the following link: https://mcuoneclipse.com/2014/10/04/emulating-eclipse-run-with-debug-configuration/
Hope this could help.
Jorge Alcala
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I'm sorry but the debugging interface has been set by one of my prof. How do I know?
I made a sreenshot to show how it looks breakpoint.