UART0 interrupt

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

Freya
Posts: 58
Joined: Mon Jun 11, 2012 11:57 am

UART0 interrupt

Thu Jan 08, 2015 3:28 pm

Hi to all,
I am experiencing a weird problem.
I realized a my own board (just say board A) and its driver classes (UART, SPI, SD using SPI,....) and i worked.
I realized another board (say board B) and I used the same driver and MCU (SAM3SB4) changing the pin used according with the new schematic and . . . it crashes!!!
Now I implemented a minimum subset of classes (LED, IO to interface with pc and SPI classes) and they worked fine.
I added the SD class and I cannot recive data from pc.
To get data from pc I use uart0 (PA9 and PA10) and the following interrupt routine:

Code: Select all

uint8_t iocnt = 0;

void UART0_Handler()
{
	uint8_t c;
	
	myio.DisableInterrupt(UART_IER_RXRDY);
	c=myio.ReadRegister();
	if((c != '\n') && (iocnt < IO_MAXCOUNT))
	{
		iobuffer[iocnt++] = c;
	}
	else
	{
		iobuffer[iocnt] = 0;
		myio.PrintString(iobuffer, '\n',0);
		iocnt = 0;
	}
	myio.EnableInterrupt(UART_IER_RXRDY);
	return;
}
In the SD class I left only constructor and the following function

Code: Select all

uint32_t MYSD::CheckMount()
{
	myio.PrintString((uint8_t *) "SD Spi address =",' ',0);
//	myio.PrintDec(piob->PIO_PDSR, '\n');
	
	return mounted;
}
If I do not use that function, the interrupt routine works.
If I use it I lost the first character I receive, or I receive nothing at all.

Why???????
PrintString() is used elsewhere and it have no problems, why here it interfiere with interrupt.

I use also the following pins:
MATRIX->CCFG_SYSIO = 0xF0; // PB7 | PB6 | PB5 |PB4 ( SD0_ChipSelect | LED3 | LED4 | SD0_CardDetect)


Any suggestion where I can look at?
Do I miss something in datasheet?
Do I have to modify some compiler options (I use standard)?

Thank you
Freya
Freya
Posts: 58
Joined: Mon Jun 11, 2012 11:57 am

Re: UART0 interrupt

Thu Jan 15, 2015 3:12 pm

Hi to all,
the problem seems to be solved moving the statement:

uint32_t sector[512];
.


From inside a class (not ioclass) to outside (declaring it as global variable)
I am afraid it could be a misunderstanding between me and the compiler.
How can I disable the optimization option in compiler?

Thank you

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 9 guests