Soft_UART_Init problem

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
tek66tim
Posts: 6
Joined: 08 Sep 2015 04:14

Soft_UART_Init problem

#1 Post by tek66tim » 08 Sep 2015 04:32

Hi,

I'm new to the MikroC AVR compiler. I have a problem with Soft_UART_Init. If I write Soft_UART_Init(&PORTE, 1, 0, 115200, 0) I get "Undeclared identifier PORTE in expression" is there an include I'm missing or something?

I have checked the checkbox next to the soft uart library. I'm using an Xmega part.

Thanks
Tim

User avatar
aleksa.jovanovic
Posts: 526
Joined: 30 Jun 2015 08:48

Re: Soft_UART_Init problem

#2 Post by aleksa.jovanovic » 08 Sep 2015 11:37

Could you post your project in a zipped file?

Best regards,
Aleksa

tek66tim
Posts: 6
Joined: 08 Sep 2015 04:14

Re: Soft_UART_Init problem

#3 Post by tek66tim » 08 Sep 2015 13:04

Hi Aleksa,

Unfortunately I can not post my project, the code is proprietary to my customer and I had to sign an NDA to consult on this project. The problem is simply that the compiler MikroC PRO AVR is choking on Soft_UART_Init(&PORTE, 1, 0, 115200, 0).

I get the error "undeclared identifier PORTE in expression"

I'm using the ATxmega128D chip. I have looked at the ATxmega128d.c file and can find no definition for PORTE (I'm assuming that's my problem). Does some kind of definition (code of some kind) need to be added to the ATxmega128d.c file for your built in functions for software uart to work on the xmega chip?

Thanks,
Tim

User avatar
aleksa.jovanovic
Posts: 526
Joined: 30 Jun 2015 08:48

Re: Soft_UART_Init problem

#4 Post by aleksa.jovanovic » 08 Sep 2015 15:16

Could you write a small example demonstrating this event?

Best regards,
Aleksa

tek66tim
Posts: 6
Joined: 08 Sep 2015 04:14

Re: Soft_UART_Init problem

#5 Post by tek66tim » 08 Sep 2015 17:19

OK. The hardware uart works fine. The compiler chokes on Soft_UART_Init(&PORTE, 1, 0, 115200, 0); with "undeclared identifier PORTE in expression".

I'm using the ATxmega128d3 chip.

I have the following libraries checked
C_math
C_type
EEPROM
PrintOut
SoftwareUART
TWI
UART

Code: Select all

void setupClock();
void printHandler(char c);


void main() 
{
	setupClock();
	UARTD0_Init(115200);
	Soft_UART_Init(&PORTE, 1, 0, 115200, 0);   
	
	do
	{
		printOut(printHandler, "hello\r\n");
		Soft_UART_Write('C');
		Delay_ms(500);
	}
	while(1);
}

void setupClock()
{
	OSC_CTRL = 0x02;
	while(RC32MRDY_bit = 0);
	
	CPU_CCP = 0xD8;
	CLK_PSCTRL = 0;

	CPU_CCP = 0xD8;
	CLK_CTRL = 1;
	
	DFLLRC32M_CTRL = 1;
}

void printHandler(char c)
{
	UARTD0_Write(c);
}

User avatar
aleksa.jovanovic
Posts: 526
Joined: 30 Jun 2015 08:48

Re: Soft_UART_Init problem

#6 Post by aleksa.jovanovic » 09 Sep 2015 14:18

Hi,

Please place the mlk file from the attachment to Mikroelektronika>mikroC PRO for AVR>Uses

It is modified so the init looks like this
Soft_UART_Init(&PORTD_IN, &PORTD_OUT, 2, 3, 14400,0);
So one is declared as input and the other as output

The baud rate should be 14400 because some issues arise from using another baud rate.

These modifications will be forwarded to our software department and implemented on the future upgrade.

Best regards,
Aleksa
Attachments
SOFT UART.rar
(89.96 KiB) Downloaded 178 times

tek66tim
Posts: 6
Joined: 08 Sep 2015 04:14

Re: Soft_UART_Init problem

#7 Post by tek66tim » 09 Sep 2015 14:47

Aleksa,

I'll give it a try. Is 14400 the highest baud rate, even with no interrupts enabled in the rest of my code and the processor core clock running at 32MHz?

Thanks,
Tim

User avatar
aleksa.jovanovic
Posts: 526
Joined: 30 Jun 2015 08:48

Re: Soft_UART_Init problem

#8 Post by aleksa.jovanovic » 10 Sep 2015 08:14

You can try to go higher, but I've gone up until it started working correctly.

Best regards,
Aleksa

Post Reply

Return to “mikroC PRO for AVR General”