[LPC1343] Uart send

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[LPC1343] Uart send

6,088件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Fri Apr 15 05:00:29 MST 2011
Hi people,

I am trying to send data to my pc. I already found the example code for the 1343.
It sends the incomming chars back.
I already tried a few things but could not get it working. The only thing the lpc needs to do is send some integer value's to my pc. The communication between pc and lpc already works fine. I am using an zigbee module to send the data.
The lpc does not need to read any incomming data.

Hope someone could help me showing how to send integers to my pc.

Lithium
0 件の賞賛
返信
54 返答(返信)

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed Apr 20 11:24:58 MST 2011
Could not resist, added you at skype :)
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Apr 19 17:39:34 MST 2011

Quote: Rob65

Not new to programming (I built my first 6502 machine way back in 1981)



You're old Rob 65 02.;)  Did you also read Dr. Dobb's Journal?:)
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Tue Apr 19 14:21:01 MST 2011
Hi guys,

some nice info. I've read some stuff that I've never seen before.
Not new to programming (I built my first 6502 machine way back in 1981) but I was used to command line tools where I had to create my own makefiles, dependencies, linked scripts etc. Even with > 10 years of experience with ARM processors (I used to be more fluent in ARM assembly than in C) this thread contains some nice info - [B]Thanks![/B]

I am one of these guys that love to stay as close to the silicon as possible and as such I have been programming a lot of low level stuff like startup code, drivers for hardware IP blocks (like I2C, Uart, SPI, PWM etc).
When programming in C I mostly start with figuring out how to best do a job.
One trick - already mentioned - is to get rid of floats. I use integers or fixed point math. Just as an example:

I created a speedometer for my bike (it's more of a complete board computer) and I wanted to count my total distance in meters/kilometers. One 32 bits integer will store up to 2^32 meters which is more than enough
My wheel size is measured in mm (2026 mm/revolution) and I have been thinking how to do this without using floats or loosing precision.

Easy: take a second variable to count the number of revolutions. As soon as I reach 1000 revolutions I add 2026 to my traveled distance (odo) - Since 1000 (revolutions) x 2026 (mm) = 2026 meters that is perfectly legal without loosing any precision.

void sensor_irq(void)
{
    if(revs++ > 999)
    {
        odo_meters += wheelsize;
        revs -= 1000;
    }
}
Is as simple as the irq which is called for every sensor tick is.
Not completely - I also keep track of the time (in msec resolution) at which the irq is triggered.
My current speed now is wheelsize / time. Wheelsize in mm, time in msec gives the speed in mm/msec which equals m/s. 1 m/s equals 3.6 km/hour (3600 * 1m = 3.6 km) so by calculating the speed as:

speed = wheelsize * 36 / time

I get the speed in a 0.1 km/hour resolution. All this in 25 lines of C code or 200 bytes of memory storage.

Placing the decimal point at the right place is all it takes to give the user a feeling of floating point math.

As soon as Lithium discovers what this can mean to his application ...
And wait to see what happens when he discovers the possibilities of the debugger :eek: (you should really try single stepping through blinky, look at variables, place breakpoints, start learning what LPCXpresso can mean for your program development).

I could talk for hours about this kind of stuff and if there are enough persons in the Netherlands willing to listen I could be persuaded to do this in front of a group

Rob
(-at- myvoice -dot- nl or skype rob.65)
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 11:28:36 MST 2011
I need at least 2 adc's. Could try it with one, i can use one or two battery's.
When using 2 of course i want to know the status of both battery's
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 11:27:22 MST 2011
PIO1_11 has just 2 functions: GPIO or AD7 :)
0 件の賞賛
返信

4,477件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 11:22:28 MST 2011
I need 2 for sure, and if i2c does not work well for this project i need 6 more indeed.
On all the adc pins is something like capture match or something.
0 件の賞賛
返信

4,477件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 11:20:18 MST 2011
You have [COLOR=Red]8[/COLOR] input pins with ADC function (AD0-AD7) :eek:
Do you need all of them for other functions ??
0 件の賞賛
返信

4,477件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 11:10:19 MST 2011
That is an good advice.
I dind't look at the pinout anymore, didn't stand still by the fact i can use the pin only for one function.
I only use the debugger for the pauze button etc, to see how it loops and where i got an error.
Never have seen or heard something about  Peripherals-IOCON.
I also wanted to use adc, i cant use that anymore.
I think it is important for me to know how full the battery is then sending data to the computer.
It's also slower then no uart.
0 件の賞賛
返信

4,477件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 10:32:05 MST 2011
You can use every pin just for 1 function :)

So select this function according to:

Chapter 6: LPC13xx I/O configuration

and don't forget to use Peripherals-IOCON view in debugger to control if somewhere else this functions have been changed unintended.

Use survey in

Chapter 7: LPC13xx Pin configuration

to find the corresponding pins.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 10:15:49 MST 2011
Do you know how to use a debugger?     Only use it to see some vars in the program and a little debugging.
Do you know how to configure IO pins? Yes i know, did in my program, i did not manually set the pins, enableing the timer will do the job.

If i change timer32 to 1 i will use the ad pins, can i use the ad converter at the same time as timer32 1?

Why when using timer 0 the pins are used? Can i not use them anymore?
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 09:27:44 MST 2011
Do you know how to use a debugger?
Do you know how to configure IO pins?

You've successfully configured PIO1_6 and PIO1_7 for CT32B0_MATCH function.

Therefore they will not work as UART at the same time. :mad:
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 08:42:41 MST 2011
yes i now tried, it isn't complaining about printf anymore but it still does not work.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 08:39:06 MST 2011
Your compiler is complaining about printf ('implicit declaration...')

= can't find it  :mad::mad::mad::mad:

Did you try to include STDIO in your main?

#include "stdio.h"


Result:

text       data        bss        dec        hex    filename
  17320        764       1052      19136       4ac0    blinky.axf
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 08:19:29 MST 2011
I have added that line for the printf into settings, symbols and then by definned symbols.

I used the blinky project from version 3,5. Deleted many files that i do not use.
There could be something wrong with my project, i do not have any understanding about building my own project etc.

I have some includes in my project, i have got 7 files.
CMISv1p30_lpc13xx/inc
And 6 more files like:
lpcexpresso3.5/tools/arm....
lpcexpresso3.5/tools/lib...
lpcexpresso3.5/tools/lib...
lpcexpresso3.6/tools/arm....
lpcexpresso3.6/tools/lib...
lpcexpresso3.6/tools/lib...

Let me see if i can export my project.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 08:11:25 MST 2011

Quote: Lithium
I did a try.
Before (with floar):  29604
After(without float): 26988
After(without float without printf) 6096



There's still a problem with printf :eek: 20k is far too much. Did you check your included libs ?


Quote: Lithium

How about the rest of my program, is it very bad?



No :)

I would suggest you copy your project and reduce this copy step by step.

If there is nothing left except a few lines in main and this effect is still there, export and post it. I think there is something wrong with your project settings or includes.
6k is a good value for this simple program, but with printf you should be somewhere at 14k.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 16 07:52:49 MST 2011
I did a try.
Before (with floar):  29604
After(without float): 26988
After(without float without printf) 6096

The print function still does not work, i am doing something wrong.
Now i do not use any floating value's.
How about the rest of my program, is it very bad?
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Apr 15 16:13:23 MST 2011
For this few calculations float Lib is a complete waste of Flash :eek:

Lines like:

      roll = (timer_1 * gainrx) - (gainroll * gyro_x);
     
are working even faster with integer:

    roll = ((timer_1 * gainrx) - (gainroll * gyro_x))/100;
   
with gainx values from 0-100.
   
So you can avoid all floats and therefore float Lib, which costs you a huge amount of flash.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Fri Apr 15 15:34:58 MST 2011
I could try to make a function to send my own integers, not sure if that will work for me.

I will post my main file. It is not 100% efficient i know that. I do not have 25 years of experience.
I know many calculations can be done without floats, i am trying to build a quad copter with an gyroscope and an accelerometer.
The problem now is only for the gyroscope. There float is very important, i need to set just the right gain to let him fly straight. Do you understand how i mean it?

Hope you can help me a bit.
I want to send the vars like m1, m2... gyro_x y and z, rx, etc.

I can now compile the code with printf but i do not get anything on my terminal.
Trying the example in this topic and everything works fine.
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri Apr 15 15:01:12 MST 2011
Post your code for us to review and to give you pointers (pun intended).  You don't have to post it all, but that would help.  We promise not to be too critical and won't make fun of you.  Well maybe just a little bit.;)
0 件の賞賛
返信

4,480件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Apr 15 14:43:32 MST 2011

Quote: Lithium
It did have some effect now used: 29588

I have seen the link, why to buy the 1227 and not the 1769? The 1769 has 512K flash memory, that is more then 128K.
I also need a fast processor, i need to use math with floating points for that i need a high frequency.
Could you please explain that to me.



Options:

1. Write your code denser

2. Use -0S Optimization as suggested in

http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization

3. Use itoa()

4. Use your own function to transmit integers

5. Use integers instead of floats. A lot a calculations can be done without float.

32k are a lot of Flash. I can't believe that you need 32k for a few functions, so your problem isn't solved yet. 128k is a huge amount of Flash. Even projects with USB, Ethernet, CAN, I2C EEPROM, UART, serial CAM don't need more than 50k.

If you ever plan to build your own board, you will be happy to use a LQFP48 instead of LQFP100.

And last but not least I don't want to answer all this questions again for LPC1769 :eek:
0 件の賞賛
返信