Lpcxpresso 1343 send string

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

Lpcxpresso 1343 send string

685 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Mon Jun 20 23:16:53 MST 2011
Hi,
I'm new in the world of embedded programming.
I have a lpcxpresso 1343, I have tried to connect to my pc with serial port 9 pin... and hyperterminal emulator on my pc but i can't write a program that send a string in a hyperterminal.
Can you help me?

Thanks Ivan
0 Kudos
18 Replies

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by richardc on Wed Jun 22 03:30:30 MST 2011
Ive programmed a chip with new firmware, but now cannot get access to the ISP. How can i restore the chip back to the ISP (so i can start programming from scratch)?
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 08:34:16 MST 2011

Quote: Serge
Did you measure the rs232 voltages? Or was it just the output of the 1343 UART?



I measure rs232 voltages... :)


Quote: Zero
With adding a simple pnp you can connect your 1343-TxD to RS232:

http://freecircuitdiagram.com/2009/03/27/simple-ttl-rs232-level-converter-using-transistor/



Thanks alot... :):):)
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jun 21 07:04:07 MST 2011
With adding a simple pnp you can connect your 1343-TxD to RS232:

http://freecircuitdiagram.com/2009/03/27/simple-ttl-rs232-level-converter-using-transistor/
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Tue Jun 21 06:49:00 MST 2011
5v and ground? then you are indeed lucky. You should read this: http://en.wikipedia.org/wiki/RS-232 . I know that todays converters use charge-pumps to get the + 12 and -12 volt levels. So with just a bit of luck (cheap capacitors :rolleyes:) the UART in the 1343 should survive. Anyway i was not directly afraid for the positive values but more for the negative ones. As I am not mistaken (please correct me here) but a 1 gives a -12V signal and a 0 relates to +12V.

More important is the way you measured the 5 volt. Was it with the uart and the rs232 connected together? Did you measure the rs232 voltages? Or was it just the output of the 1343 UART?
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 06:27:13 MST 2011

Quote: Serge
The RS232 levels are -12V and +12V:eek:. You have a possibility that the UART port of your 1343 died. Those pins are 5V compatible but i am afraid that 12V will be a little too much so ... pray :rolleyes:that your USB-RS232 converter was not one of a better quality :D



I test the rs232 connector with digital multimeter and levels that TX and RX pin are 5v...
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 06:00:46 MST 2011
thanks to all :)
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Tue Jun 21 05:39:30 MST 2011
The RS232 levels are -12V and +12V:eek:. You have a possibility that the UART port of your 1343 died. Those pins are 5V compatible but i am afraid that 12V will be a little too much so ... pray :rolleyes:that your USB-RS232 converter was not one of a better quality :D
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jun 21 04:20:52 MST 2011
Did you read:

http://knowledgebase.nxp.com/showthread.php?t=1931

There I've described how to throw out RS232 parts of your cheap RS232<->USB adapter.

That's my favorite solution :)
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Tue Jun 21 04:18:37 MST 2011
You can also disassemble your RS232-USB converter. Quite likely it consists of a level converter and a TTL-USB chip. You can just connect to the TTL pins directly.
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Skashkash on Tue Jun 21 04:15:14 MST 2011

Quote: ivan
I did not know .... :eek:
so what should I use to connect to my PC? :confused:



If you wish to avoid soldering, something along the lines of:
http://www.adafruit.com/products/70
or
http://www.sparkfun.com/products/9873

Else there are chips to convert 3.3v logic signals to rs-232 levels.
http://datasheets.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf


-skashkash
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Tue Jun 21 04:14:40 MST 2011
http://cgi.ebay.com/USB-2-0-TTL-UART-6PIN-CP2102-Module-Serial-Converter-/150604665815?pt=LH_Default...

use something like this
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 04:05:12 MST 2011

Quote: Zero
RS232 is not TTL :eek:

Please read:

http://knowledgebase.nxp.com/showthread.php?t=1931



I did not know .... :eek:
so what should I use to connect to my PC? :confused:
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jun 21 03:56:00 MST 2011
RS232 is not TTL :eek:

Please read:

http://knowledgebase.nxp.com/showthread.php?t=1931
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 03:51:43 MST 2011

Quote: Zero
If you are really connecting your 1343 direct to your 232<->USB adaptor, that's your mistake :confused:



Why?
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jun 21 03:48:32 MST 2011
If you are really connecting your 1343 direct to your 232<->USB adaptor, that's your mistake :confused:
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Tue Jun 21 03:39:57 MST 2011
I use tera term... i connect txd to pin 2 and gnd to pin 5... of the serial port...
I use this http://www.lindy.it/shop/showProductDetail.do?orderNumber=42855&source=search usb to rs232 convert...

I do not understand where the mistake... :(
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jun 21 03:07:19 MST 2011
Good news, your code is working :)

So you have either a hardware problem with your UART<->whatever adaptor or Hyperterminal is kidding you :mad:

('Tera Term' (http://en.sourceforge.jp/projects/ttssh2/downloads/51174/teraterm-4.69.exe) is a common used more reliable program)
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan on Mon Jun 20 23:59:49 MST 2011
This is my code:

/*
===============================================================================
Name        : main.c
Author      : Ivan
Version     : 1.0
Copyright   : Copyright (C) 2010 noritan.org
Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC13xx.h"
#endif

#define SystemFrequency SystemCoreClock
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

// Flag mask for UART_LSR register.
const uint32_t LSR_THRE = 0x20;

// Initialize UART module with specified baud-rate
void uart_init(uint32_t baudrate) {
    // Divisor ratio
    uint32_t                    Fdiv;
    uint32_t regVal;
    // Configure P1[7] as TXD output.
    LPC_IOCON->PIO1_7 &= ~0x07;         // FUNC=000 (GPIO)
    LPC_IOCON->PIO1_7 |= 0x01;          // FUNC=001 (TXD)

    // Enable UART clock
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);   // UART=1

    // Enable UART peripheral clock
    LPC_SYSCON->UARTCLKDIV = 0x01;      // DIV=1

    // Calculate baud rate divisor
    regVal = LPC_SYSCON->UARTCLKDIV;
    Fdiv = (((SystemFrequency/LPC_SYSCON->SYSAHBCLKDIV)/regVal)/16)/baudrate ;

    // Set the baud rate divisor value
    LPC_UART->LCR |= 0x83;
    LPC_UART->DLM = Fdiv / 256;
    LPC_UART->DLL = Fdiv % 256;
    LPC_UART->LCR &= ~0x83;

    // Configure UART module as
    //   8 bit, 1 stop bit, no parity
    //   Enable and reset TX and RX FIFO.
    LPC_UART->LCR = 0x03;
    LPC_UART->FCR = 0x07;
}

// send a character via TXD
void uart_putc(const char c) {
    // Wait for TX buffer empty
    while (!(LPC_UART->LSR & LSR_THRE));
    // Put a character
    LPC_UART->THR = c;
}

// send a string via TXD
int uart_puts(const char *s) {
    int n;
    for (n = 0; *s; s++, n++) {
        uart_putc(*s);
    }
    return n;
}

// Main loop
int main(void) {
    uart_init(115200);
    uart_puts("ciao");

    // Enter an infinite loop, just incrementing a counter
    volatile static int i = 0 ;
    while(1) {
        i++ ;
    }
    return 0 ;
}
0 Kudos