FRDMK22F_AGM01 and ESP8266 connection

cancel
Showing results for 
Search instead for 
Did you mean: 

FRDMK22F_AGM01 and ESP8266 connection

Jump to solution
295 Views
Contributor II

I have solved the following problemsFRDM-K22F-AGM01 how to communication with other board? . but now I have a new question...

I need to transfer data to the cloud via wireless network, there is an ESP8266 device and ESP8266 Writer(fig.1), but FRDM-STBC-AGM01+FRDM-K22F does not provide TX and RX pins(fig.2). Is there any solution to establish transmission between these two devices?

IDE:MCUXpresso and IISDK support

fig.1

pastedImage_4.png

fig.2

pastedImage_5.png

1 Solution
142 Views
Senior Contributor II

Hi g0930421313@gmail.com‌,

At first glance, the code looks good.  

But it looks like you have to understand how pin functionality is set using the Pin MUX.  

I think the easiest way for you to do this is to specify PTA1 & PTA2 as UART0_RX & UART0_TX, respectively using the Pin Wizard in MCUXpresso.  

Once you have done that, put an oscilloscope probe to PTA2 (J1-4/D3) and see if you get signals out.  Once you have changed the "DEMO_UART" defines to UART0, I would recommend changing the send/receive loop above to:

while (1)
{
//  UART_ReadBlocking(DEMO_UART, &ch, 1);

  ch = 0x55;  // 'U'
  UART_WriteBlocking(DEMO_UART, &ch, 1);
}

So that a byte of alternating ones is sent repeatedly and is easier to see on the oscilloscope.

Good luck!

myke

View solution in original post

5 Replies
142 Views
Senior Contributor II

Hi g0930421313@gmail.com‌,

If I understand your question correctly, you are looking for a UART RX & TX to connect the FRDM-K22F to the ESP8266 Writer board?  It looks like you also need some GPIO, but I think that's less of an issue as there looks like there are a number of DI/DOs available on the FRDM-K22F.  

I think I have a reasonable understanding of the FRDM-K22F board and I think I understand the connections between it and the AGM01 board.  Unfortunately, the pinouts of the connectors on the two boards are not easily cross referenced.  

Looking at the AGM01 QRC and the FRDM-K22F's schematics, AGM01's J1-1 corresponds to the FRDM-K22F's J1-2 which is "D0".  With this, you can go down the pins on the left side of your "Fig. 2" as:

  AGM01                   FRDM-K22F

  J1-1                    D0

  J1-2                    D1

  J1-3 (INT1-8700)        D2

  J1-4                    D3 (PTA2/UART0_TX/FTM0_CH7/GREEN LED)

  J1-5 (INT2-8700)        D4

  J1-6 (INT1-21002)       D5

  J1-7                    D6

  J1-8                    D7

  J2-1 (INT2-21002)       D8

  J2-2                    D9 (PTA1/UART0_RX/FTM0_CH6/RED LED)

  J2-3 (SPI-CSB-21002)    D10

  J2-4 (SPI-MOSI)         D11

  J2-5 (SA0-MISO)         D12

  j2-6 (SPI-SCLK)         D13 (PTD5/FTM0_CH5/SPI1_SCK/BLUE LED)

If I understand what's happending correctly (and I don't think I'm 100% right), AGM01 J1-4 (FRDM-K22F D3) and AGM01 J2-2 (FRDM-K22F D9) are unused.  You'll note that these pins are the Tx/Rx of UART0 and you should be able to use them but...

They are also used to drive the red and green LEDs on the FRDM-K22F.  If you are going to use these pins for the RX & TX, I highly recommend that you remove R91 and R92 on the FRDM-K22F so the current sink of the LEDs don't affect the serial operations. 

I would recommend running the signals from D3 and D9 of the FRDM-K22F out using an Arduino prototyping shield (I use PROTO-SHIELD - it's cheap and easy to work with).  

I notice in the QRC that the SPI1_SCK is used on J2-6, which corresponds to D13 and drives the blue LED on the FRDM-K22F - while you're removing R91 & R92, I would recommend that you also remove R93 so the load of the blue LED doesn't affect your SPI operations (in my prototyping with the FRDM-K22F, I use SPI1 as well and I found I had to pull R93 for best operations).  

Good luck, let me know how you make out or if I'm completely out to lunch in my interpretation of the documentation (such as it is).

myke

142 Views
Contributor II

Hi

My question description may not be detailed enough.

I expect to write a program to upload data on ARDUINO IDE, and burn the program to the ESP8266 at the top left of "Fig.2" via ESP8266 WRITER so that the received data can be uploaded to the cloud database, and the pins need to be wired  on this board.
What bothers me now is how to transfer the data sensed by FRDMK22F_AGM01 to ESP8266. The pins of the board are currently soldered (FIG.1)

After reading your answer, I don’t understand how to "remove R91 and R92 on the FRDM-K22F"?

Thanks!
FIG.1

FIG.2

0 Kudos
142 Views
Senior Contributor II

Hi g0930421313@gmail.com‌,

From your reply, it sounds like you're going to have to find somebody who is familiar with electronics and is handly with a soldering iron.  

I wasn't explicit, but it looks like you're going to have to run wires from the FRDM-K22F's D3 & D9 pins to the ESP8266 board,s TXD & RXD to communicate with it.  You may also have to run a few GPIO's to it but I don't have access to the EXP8266 board's datasheet.  

Good luck.  

myke

0 Kudos
142 Views
Contributor II

Hi

I have followed  your method and UART pins. How can I modify the code to send & receive data via J1-4 & J2-2?

I use the IISDK example "uart_polling" in MCUXpresso IDE  and  tried to replace the DEMO_UART to UART0 or UART2 in definitions(following code), but the data still cannot be transmitted successfully.

Thanks!

======code=======

#include "board.h"
#include "fsl_uart.h"

#include "pin_mux.h"
#include "clock_config.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define DEMO_UART UART1
#define DEMO_UART_CLKSRC SYS_CLK
#define DEMO_UART_CLK_FREQ CLOCK_GetFreq(SYS_CLK)

/*******************************************************************************
* Prototypes
******************************************************************************/

/*******************************************************************************
* Variables
******************************************************************************/

uint8_t txbuff[] = "Uart polling example\r\nBoard will send back received characters\r\n";
uint8_t rxbuff[20] = {0};

/*******************************************************************************
* Code
******************************************************************************/
/*!
* @brief Main function
*/
int main(void)
{
uint8_t ch;
uart_config_t config;

BOARD_InitPins();
BOARD_BootClockRUN();

/*
* config.baudRate_Bps = 115200U;
* config.parityMode = kUART_ParityDisabled;
* config.stopBitCount = kUART_OneStopBit;
* config.txFifoWatermark = 0;
* config.rxFifoWatermark = 1;
* config.enableTx = false;
* config.enableRx = false;
*/
UART_GetDefaultConfig(&config);
config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
config.enableTx = true;
config.enableRx = true;

UART_Init(DEMO_UART, &config, DEMO_UART_CLK_FREQ);

UART_WriteBlocking(DEMO_UART, txbuff, sizeof(txbuff) - 1);

while (1)
{
UART_ReadBlocking(DEMO_UART, &ch, 1);
UART_WriteBlocking(DEMO_UART, &ch, 1);
}
}

0 Kudos
143 Views
Senior Contributor II

Hi g0930421313@gmail.com‌,

At first glance, the code looks good.  

But it looks like you have to understand how pin functionality is set using the Pin MUX.  

I think the easiest way for you to do this is to specify PTA1 & PTA2 as UART0_RX & UART0_TX, respectively using the Pin Wizard in MCUXpresso.  

Once you have done that, put an oscilloscope probe to PTA2 (J1-4/D3) and see if you get signals out.  Once you have changed the "DEMO_UART" defines to UART0, I would recommend changing the send/receive loop above to:

while (1)
{
//  UART_ReadBlocking(DEMO_UART, &ch, 1);

  ch = 0x55;  // 'U'
  UART_WriteBlocking(DEMO_UART, &ch, 1);
}

So that a byte of alternating ones is sent repeatedly and is easier to see on the oscilloscope.

Good luck!

myke

View solution in original post