Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() functionality #18

Open
wants to merge 1 commit into
base: linux-descriptors
Choose a base branch
from

Conversation

RacingTornado
Copy link

sudo minicom -H -w fastuart

You should have the parameters of fastuart set to 115200. You should see the values on the terminal.

The PA2 pin must be connected to the rx pin on the serial adaptor. In this situation , the ground must be the same also. Else you may get receiving errors.

The idea is to use this for debugging purposes. The baud rates is set to 115200 by setting the delay values.

Another important fact is that the console must be first opened up before loading the firmware onto the FX2. This is required for getting a lock on the start and the stop bits since there is no line break attached between the 2 bytes.

Code has been cleaned up and the firmware in the examples directory is extremely small(less than 5-6 lines)
Assembly has been extensively commented.
I would like to merge this with the linux-descriptors branch since this is what I used as a base

@RacingTornado RacingTornado changed the title Created a UART API definition in softuart.h to allow the example code to access printf() and scanf() functionality Implemented UART in keeping with the API definition in softuart.h to allow the example code to access printf() and scanf() functionality Jun 24, 2016
@RacingTornado RacingTornado changed the title Implemented UART in keeping with the API definition in softuart.h to allow the example code to access printf() and scanf() functionality Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() and scanf() functionality Jun 24, 2016
@RacingTornado RacingTornado changed the title Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() and scanf() functionality Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() functionality Jun 24, 2016
@mithro
Copy link
Owner

mithro commented Jun 24, 2016

This is starting down the right path, but there are a couple of big things which need to change.

As I described in my email, there should be a function / macro something like CREATE_FAST_UART(<uart name>, <tx pin>). Calling this should generate a bunch of functions with names like uart0_init, uart0_rx etc (assuming <uart name> was set to uart0).

This allows you to create two uarts on two different pins which can be used at the same time.

Your comments about the API are misleading too. It very much does matter what you return for the queue count.

When commenting your ASM, you should align things like cycle counts above each other.

@mithro
Copy link
Owner

mithro commented Jun 24, 2016

Please write your setup/testing instructions in the form of valid shell commands too.

#include <stdio.h>
#include <uart/api.h>

//Used for setting the baud rate.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't define things you are not using at the moment.

@RacingTornado
Copy link
Author

RacingTornado commented Jun 24, 2016

This allows you to create two uarts on two different pins which can be used at the same time

I am a little confused as to how you plan to achieve this.
#define something(name,func) name##some"()"
something(hello,1)
From what locations so you plan to call this. I am not sure I understand this feature completely. Wont it just be better to have a function which sets the pin in api.h and implement this since the function fast_uart blocks anyway. I dont seem to understand "same_time" means in this context

@RacingTornado
Copy link
Author

RacingTornado commented Jun 25, 2016

When commenting your ASM, you should align things like cycle counts above each other.

This is kind of hard but I have tried doing it

@mithro
Copy link
Owner

mithro commented Jun 25, 2016


BOOL uartX_set_baud(enum uart_baud rate)
{
switch(rate)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually didn't mean for you to implement all the baud rates, just to return an error when the baud rate was not BAUD_115200. However, as you have already done it now we can leave it here.

@RacingTornado RacingTornado force-pushed the fast_uart_try3 branch 6 times, most recently from 4f4d855 to 5076805 Compare June 25, 2016 13:14
@@ -0,0 +1,15 @@
#!/bin/bash -e
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This download script should probably be shared between all examples. Can you move it into the examples directory and send it as a separate pull request.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could then have it as part of the common Makefile..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

void main(void)
{
baud = BAUD_115200;
uartX_init(baud);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be called "uart0_init" as we discussed? Are you waiting on something from me?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have a question. If I call printf(), how does it know which uart to connect to.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need a function in the firmware which maps puts to the correct uart function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putchar() can be mapped to one uart.How do we do this for more than 1 and dynamically? Once again I think things would be easier once I create and commit the macro.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit.

@mithro
Copy link
Owner

mithro commented Jul 3, 2016

This still need a bunch of work before it can be merged.

Couple of things which need to be done are;

  • Test with two UARTs.
  • How fast can this UART operate if you don't have any delays?
  • If you don't disable the ISR and is the corruption detectable?

As I mentioned previously, this UART is mainly for debugging -- so we want it to be fast and have minimal impact on the system. This probably means we are going to be okay with using a non-standard BAUD rate here.

SETCPUFREQ(CLK_48M);
while (TRUE)
{
printf("Hello");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a \r\n to the printed string

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@RacingTornado RacingTornado force-pushed the fast_uart_try3 branch 4 times, most recently from 7ce523c to 82ae218 Compare July 5, 2016 05:26
OEA = bitnum; \
uart_tx(c); \
} \
BOOL uartname##_set_baud(enum uart_baud rate) { \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something funky. On gedit it is aligned(using tabs). Which editor do you want to use? Autoindenting in astyle is not able to align the \

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care what editor you use. I care that you set up your editor to produce the correct result. If you find it too hard to do that in gedit, you are welcome to try a different one.

I personally use vim, but it has a very steep learning curve.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like only this diff view is showing this. The normal file here is https://github.com/RacingTornado/fx2lib/blob/9b86ebfe1bb807bdca802db8da0f271c2ed574e5/include/uart/soft_uart.h looks okay

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normal file is also showing the weird wrapping.

Copy link
Author

@RacingTornado RacingTornado Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not showing it for me . I sent you an email with a picture.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

DSCR_AREA=
INT2JT=
include $(FX2LIBDIR)/lib/fx2.mk
fx2_download:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target should be part of fx2.mk file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@mithro
Copy link
Owner

mithro commented Jul 11, 2016

This code still needs a whole bunch more work and I'm pretty sure if it does work, it is only by accident.

@RacingTornado
Copy link
Author

RacingTornado commented Jul 11, 2016

This code still needs a whole bunch more work and I'm pretty sure if it does work, it is only by accident.

Why do you say that ? I use this extensively for debugging all my other stuff and it seems very reliable.

@RacingTornado RacingTornado force-pushed the fast_uart_try3 branch 2 times, most recently from da356b1 to 614a4c3 Compare July 20, 2016 05:52
* uart name .
**/
#define CREATE_FAST_UART(uartname,port,pinname,bitnum,TX_BLOCKING,RX_ENABLED) \
unsigned char uartname##_load_delay; \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last 2 are caps because they are TRUE or FALSE values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants