UART Build on P1025 Tower System

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART Build on P1025 Tower System

Jump to solution
2,027 Views
drs
Contributor II

I am putting together a build to use the UART on the TWR-P1025 Tower System Module. I am using freescale example code, but I am getting an error:

The build fails because the following is undefined:
__CCSRBAR

This is defined as extern in twrp1025.h.

Can anyone please help me to get this defined?

Labels (1)
1 Solution
1,575 Views
marius_grigoras
NXP Employee
NXP Employee

Hi David,

You'll need to update next files:

PA\PA_Support\Serial\Common\UART.h  -- here please add next line in UARTBaudRate enum struct:

kBaud768000 = 768000

And also replace in next file next value macro kBaud115200 with the one preconfigured above kBaud768000

More exactly this will be after update:

#define UART_CONSOLE_BAUD_RATEkBaud768000

PA\PA_Support\ewl\EWL_C\include\pa\uart_console_config.h

Now, will need to re-build your UART project and ewl libs.

For UART project just use the P1025TWR serial project presented above and just rebuild it.

For ewl libs please take a look in next chapter 22.3.3 How to Rebuild the EWL Libraries from PA\Help\PDF\Power Arch Build Tools Reference.pdf .

Please let me know any results,

Marius

View solution in original post

0 Kudos
21 Replies
1,501 Views
yipingwang
NXP TechSupport
NXP TechSupport

Which software are you using? And Which version?

1,501 Views
drs
Contributor II

I am using Code Warrior Development Studio Version 10.3. I have created a bareboard project and have added code from Freescale MQX 3.8 P1025.

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi,

Please note that CW PA10.3 already has an UART example for P1025TWR -> PA\PA_Support\Serial\P1025TWR_serial .

Which is your need more exactly?

Regards,

Marius

0 Kudos
1,501 Views
drs
Contributor II

Hi Marius,

I need to build a project that will enable me to receive serial data initially at 115200 baud. Once this is working, I will need to go on and up the baud rate, which will require me to modify the BSP/library software to increase the baud rate.

Thank you for the information on the UART example. I am not able to run this. I can build it but when I try to run in says "Launch failed. Binary not found".

I am able to import examples from Freescale MXQ 3.8 and run these.

regards,

Dave

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

Our stationary project already includes the UART lib compiled for 115200 baudrate. You cannot launch the uart project, the uart project makes a UART binary file that is included in the stationary project.

Also, if you want to increase the baudrate using only the CW support, you'll need to re-build the UART and compiler libs to your new baudrate value. Please let me know if you need this.

Regards,

Marius

0 Kudos
1,501 Views
drs
Contributor II

Hi Marius,

Is the stationary project the same as the bareboard project?

So the bareboard project already contains the UART lib?

I thought that I had to install the UART using _bsp_enable_card (in init_bsp.c), which calls _st16550_serial_polled_install_ex. This uses _bsp_duart0_init, which is where my _CCSRBAR problem came from.

So are you saying that I do not need to do this? Can I just use a call to scanf to read in the data?

Please excuse my ignorance, but I am new to this platform.

regards,

Dave

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

Yes, the stationary is the bareboard project and it contains already the UART lib already built for 115200 baudrate.

I confirm that is enough to use the bareboard project to make any printf/scanf operation.

Regards,

Marius

1,501 Views
drs
Contributor II

Hi Marius,

Is there a way to find out whether the UART buffer contains data? If I use scanf and there is no data present, then the program will get stuck waiting for the data. So it would be useful to know whether there is some data to read before calling scanf.

best regards,

Dave

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

The stdio library doesn't support the concept of non-blocking I/O (all these functions are blocking: scanf, fgets and so on).

The only portable/nice solution is to making polling (this concept is very use also in networking for un-blocking sockets) on STDIN.

Let me check please till Monday if we have support for this in EWL (P1025TWR is not gcc based in CW).

Regards,

Marius

0 Kudos
1,500 Views
drs
Contributor II

Hi Marius,

I could use _st16550_serial_getc to poll for characters, instead of calling scanf. This would be a non-blocking call, so that if the serial input stream stopped for any reason, then the program would not get stuck.

However, I need to overcome my linker error: How do I define __CCSRBAR?

Regards,

Dave

0 Kudos
1,500 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

Sorry for delayed response. Unfortunately I never used these MQX examples. Can you please tell me from where did you download these examples and how you tried to integrate these in CW for PA? I need all these for reproducing the issue on my side.

Btw, you tried to simply define this macro in your code?

#define __CCSRBAR 0xff700000

Thank you,

Marius

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

Btw, how you gonna check this "non-blocking" functionality in your case (let's assume that you have one)? Basically, if you use only scanf the stdin buffer will be fill only after scanf() call and never you'll have available date in this buffer before the blocking I/O function.

Please let me know what are you trying to do.

Regards,

Marius

0 Kudos
1,501 Views
drs
Contributor II

Hi Marius,

From what you are saying it seems that I should be using polling.

My initial attempts at reading in serial data made use of the serial polling example files (serl_pol_st16550.c) in C:\Freescale MQX 3.8 P1025\mqx\source\io\serial\polled being called from _bsp_enable_card in init_bsp.c in C:\Freescale MQX 3.8 P1025\mqx\source\bsp\twrp1025.

This is where I had the original problem with __CCSRBAR being undefined.

The design involves several tasks running under MQX, one of these is to read in a stream of serial data. Hence, as you pointed out, it could be a problem if the serial input data stream is lost, then the code would get stuck in scanf, as this is a blocking function.

I suppose then I need to come back to the question as to how to define __CCSRBAR?

Regards,

Dave

0 Kudos
1,501 Views
drs
Contributor II

Hi Marius,

thank you for the information.

Earlier I was asking about increasing the baud rate and you said that I would need to re-build the UART and compiler libs to my new baudrate value. Could you tell me how I can do this? The required baud rate has been specified as 768,000.

regards,

Dave

0 Kudos
1,576 Views
marius_grigoras
NXP Employee
NXP Employee

Hi David,

You'll need to update next files:

PA\PA_Support\Serial\Common\UART.h  -- here please add next line in UARTBaudRate enum struct:

kBaud768000 = 768000

And also replace in next file next value macro kBaud115200 with the one preconfigured above kBaud768000

More exactly this will be after update:

#define UART_CONSOLE_BAUD_RATEkBaud768000

PA\PA_Support\ewl\EWL_C\include\pa\uart_console_config.h

Now, will need to re-build your UART project and ewl libs.

For UART project just use the P1025TWR serial project presented above and just rebuild it.

For ewl libs please take a look in next chapter 22.3.3 How to Rebuild the EWL Libraries from PA\Help\PDF\Power Arch Build Tools Reference.pdf .

Please let me know any results,

Marius

0 Kudos
1,501 Views
drs
Contributor II

Marius,

I have tried to change the baud rate to 9600:

I have changed uart_console_config.h to kbaud9600

I have followed the instructions on "How to Rebuild the EWL Libraries"

I have rebuilt my project.

However, the baud rate is still 115200.

Can you think of anything I might have missed out?

regards,

Dave

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

Hi Dave,

After you compiled the compiler libs, are you sure that your project is using the new ones libs?

You need to replace your new UART1_P1025TWR.UC.a, libc_E500V2.a and librt_E500V2.a in the stationary project.

The uart lib is in the UART project (you just compiled this project under eclipse) and the rest 2 libs are in the CW layout (PA\PA_Support\ewl\lib).

After that, clean and re-compile your stationary project.

Best regards,

Marius

1,501 Views
drs
Contributor II

Hi Marius,

You were right, I did not have the new libraries. It is now working fine at 9600 baud.

Thank you very much for your very helpful answers.

best regards,

Dave

0 Kudos
1,501 Views
drs
Contributor II

Marius,

thank you very much for the information.

I will give this a try next week.

As we will not have the hardware to test at the higher baud rate. I will experiment by lowering the baud rate first.

I will let you know how it goes.

Thank you again.

regards,

Dave

0 Kudos
1,501 Views
marius_grigoras
NXP Employee
NXP Employee

One more question: I'm just curios why you need to test your hardware for such a high baudrate?

Marius

0 Kudos