Part Number Hot Search : 
GC1712 STC945N 01GW3B2 99000 F75645P 5DRWBZH 2SD1511Q 1N6663
Product Description
Full Text Search
 

To Download AN4274 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  april 2013 docid024358 rev 1 1/13 AN4274 application note the serial communication driver between the st7580 and the stm32fx by vincenzo mormina introduction this document describes the serial communication driver between the st7580 and the stm32fx. this driver is designed from st7580 power line modem devices. this firmware is available by software license agreement only: ? http://www.st.com/software_license_agreement_liberty_v2 ? http://www.st.com/software_license_agreement_image_v2 please, ask your local st office for further information. www.st.com
contents AN4274 2/13 docid024358 rev 1 contents 1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3 board support package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4 serial communication layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 5 reference documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 appendix a example of serial communication driver code . . . . . . . . . . . . . . . . 10 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
docid024358 rev 1 3/13 AN4274 overview 1 overview the st7580 serial communication driver provides services and functions to manage the serial communication (uart, usart) from the st7580 power line networking soc and the stm32fx microcontroller. the stm32fx hardware resources required to connect the stm32fx to st7580 plm are: ? serial peripheral (uart/usart) ? 3 gpio ? timer the st7580 serial communication driver provides the function to configure these peripherals. the st7580 serial communication driver is based on the stm32fx standard library to manage the peripherals used. for further details about the serial peripherals and the accepted configuration parameters, please see the st7580 and the stm32fx documentation.
firmware architecture AN4274 4/13 docid024358 rev 1 2 firmware architecture figure 1 shows the firmware architecture: figure 1. firmware architecture ? physical: ? the physical layer of the st7580 provides a basic mac service through a serial communication interface. ? stm32fx standard driver: ? it provides the stm32fx standard peripheral driver. ? bsp (board support package): ? the bsp layer defines and configures the communication peripherals used to connect the st7580 and the stm32fx. ? serial communication driver: ? it provides a serial communication function to manage the communication from the st7580 to stm32fx and vice versa. ? application layer: ? the application layer can be customized by the user; in this section the user must design the application. am16729v1 application serial comm driver physical st7580 stm32 bsp stm32 std driver
docid024358 rev 1 5/13 AN4274 firmware architecture the following figure 2 and figure 3 show the component files. figure 2. serial communication driver files the serial communication firmware module contains the files st7580_serial20.c/h.they provide fsm (finite state machine) and the functions to manage the serial data flow from and to the st7580 devices. figure 3. bsp files the bsp firmware module contains all the definitions and the configurations of the hardware resources used by the system to perform and manage the connection and serial communication from the st7580 to the stm32fx and vice versa. am16730v1 serial comm driver stm32 st7580_serial20.h st7580_serial20.c am16731v1 stm32 bsp st7580_stm32_ bsp.h st7580_stm32_bsp.c
board support package AN4274 6/13 docid024358 rev 1 3 board support package this layer defines the stm32fx peripherals used to perform the serial communication. in this file the following peripherals and linked functions have to be defined: ? uart/usart: serial connection. ? gpio: used by uart/usart, to reset the st7580 and mco pin if used. ? timer: used by serial synchronization and timeout. ? mco: external clock, if used.
docid024358 rev 1 7/13 AN4274 serial communication layer 4 serial communication layer the serial communication module defines all the functions to manage the serial data flow. the core of the serial communication driver is a " modemcomfsm " function. this is a finite state machine and must be called in an infinite loop, as follows: while(1) { state = modemcomfsm( &sercom, dl_act); switch (state) {...} } this function has the following input parameters: ? sercom , input/output parameter. it is a pointer to " ser_cmd_frame_t" struct : typedef struct{ u8 id; //host interface command code u8 rxpar_len; //reception buffer length u8 txpar_len ; //transmission buffer length u8 rxparam[255]; //reception buffer u8 txparam[255]; //transmission buffer } ser_cmd_frame_t ; ? dl_act , this parameter notifies that the data is ready to be sent; the user sets "1" to send the data. ta ble 1 defines the return values of the finite state machine: table 1. fsm return values name value fsm state description m_frame_acked 04h 1 frame sent to plm and ack arrived. m_frame_not_acked 05h 1 frame sent to plm and nack arrived (error state). m_wait_ack 06h 1 fsm waits for either ack or nack after sending data. m_frame_received 07h 2 fsm received the data from a plm, and the data is ready to be read. m_idle 08h 2 the fsm is ready to receive the data from stm32fx to be sent to plm. m_frame_valid 09h 2 the data received by stm32fx is valid. m_frame_not_valid 0ah 2 the data received by stm32fx is not valid (error state). m_frame_delivered 0bh 3 the fsm delivered the data to plm. m_wait_status 0ch 3 the fsm waits for the status of the message from plm. m_frame_confirmed 0dh 4 the data sent to plm is confirmed.
serial communication layer AN4274 8/13 docid024358 rev 1 the application layer can send frames to plm only when the fsm return state is "m_idle. if the data sent to fsm is valid, the fsm return state is "m_frame_received". m_frame_not_confirmed 0eh 4 the data sent to plm is not confirmed (error state). m_wait_confirm 0fh 4 the fsm waits for the confirmed command from plm. m_to_elapsed 10h 1-3-4 timeout elapsed (error state). table 1. fsm return values (continued) name value fsm state description
docid024358 rev 1 9/13 AN4274 reference documents 5 reference documents ? st7580 datasheet ? um0932 user manual ? an4068 application note ? stm32fx datasheet
example of serial communication driver code AN4274 10/13 docid024358 rev 1 appendix a example of serial communication driver code the following code shows how to manage the serial communication driver. the "bsp_init" is a configuration function, the parameter "com_baud_rate" is the serial speed (please see the st7580 datasheet for further details about the accepted speed values). the fsm must be inserted in an infinite loop, and the return state must be managed. the state "m_frame_received" notifies that a new data has arrived, the state "m_idle" means that the fsm is free and the data can be sent. /* init bsp */ bsp_init(com_baud_rate); /* output hse clock on mco pin */ enablemco(); /*start modem*/ modem_start; while(1) { u8 state; state = modemcomfsm( &sercom, dl_act); switch (state) { case m_frame_received:// frame receive management { /* reception management, example */ id_command = sercom.id; memcpy(&rx_buff, &sercom.rxparam, sercom.rxpar_len); rx_buffer_len = sercom.rxpar_len; } break; case m_idle:// frame transmit management { /* transmission management, example */ if(tx_state == app_true){ sercom.id = 0x50;//dl_data req id sercom.txparam[0] = 0x04;//modem transmission parameters sercom.txparam[1] = 0x01;//data 1 sercom.txparam[2] = 0x03;//data 2 sercom.txpar_len = 3; dl_act = act_tx; tx_state = app_false; } } break; case m_frame_confirmed:
docid024358 rev 1 11/13 AN4274 example of serial communication driver code { } break; case m_frame_not_confirmed: { /* put here the frames not confirmed management code */ dl_act = no_act; } break; case m_to_elapsed: break; case m_frame_valid: break; default: { state = m_idle; } break; } }
revision history AN4274 12/13 docid024358 rev 1 revision history table 2. document revision history date revision changes 23-apr-2013 1 initial release.
docid024358 rev 1 13/13 AN4274 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a particular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. st products are not authorized for use in weapons. nor are st products designed or authorized for use in: (a) safety critical applications such as life supporting, active implanted devices or systems with product functional safety requirements; (b) aeronautic applications; (c) automotive applications or environments, and/or (d) aerospace applications or environments. where st products are not designed for such use, the purchaser shall use products at purchaser?s sole risk, even if st has been informed in writing of such usage, unless a product is expressly designated by st as being intended for ?automotive, automotive safety or medical? industry domains according to st product design specifications. products formally escc, qml or jan qualified are deemed suitable for use in aerospace by the corresponding governmental agency. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or register ed trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2013 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN4274

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X