Home

FM3 FAMILY MB9A/BFXXX LOW LEVEL LIBRARY MANUAL

image

Contents

1. Type Field Possible Values Description MfsAsynchronous0 UART mode 0 MfsAsynchronousMultil UART mode 1 Master Slave MfsSynchronousMaster2 CSIO mode 2 Master em nte moce emoce MfsSynchronousSlave2 CSIO mode 2 Slave MfsI2cMaster I2C mode 3 Master MfsI2cSlave I2C mode 3 Slave MfsUseInternalBaudRate Clock for asynchronous operation Generator MfsUseExternalSerial A SM MES co enClock c M ek m E Clock for synchronous operation ells SEC t Source CSS ak MS Clock for synchronous slave operation ClockSourceAsItIs Wem je u32DataRate Bits per second MfsParityNone No parity used in mode 0 en mfs G B TINO Zase enParity MfsParityEven Even parity in mode 0 MfsParityOdd Odd parity in mode 0 MfsNoStartNoStop No start and no stop bit mode 2 SL MES E fsOneStartOneStop 1 start and 1 stop bit mode 0 1 STATE Sto Bit fsOneStartTwoStop 1 start and 2 stop bits mode 0 1 SEDE E MfsOneStartThreeStop 1 start and 3 stop bits mode 0 1 MfsOneStartFourStop 1 start and 4 stop bits mode 0 1 MfsFifeBits 5 Data bits en mfs MfsSixBits 6 Data bits u8Char a character n MfsSevenBits 7 Data bits length t E MfsEightBits 8 Data bits MfsNineBits 9 Data bits n PEREA TRUE LSB first Direction FALSE MSB first poynes TRUE boolean t Elek e S en ELIE SE Wee M SE ampling on rising edge mode 2 MfsSyncWaitZero 0 wait cycle ins
2. Prototype SMS SU CCM SRN SME C SEC STN pstcMfs UNES a u32DataRate en mra Parity T enParity en mks start stopbit enStartStopBTt MCS us Glo iF Whe iia ic p nTxCallback ques ds Clo CUNE Orr pfnRxCallback Parameter Name Description in pstcMfs Pointer to MFS instance in u32DataRate Bits per seconds in enParity Use parity or not in enStartStopBit Determines number of stop bits in pfnTxCallback Pointer to transmission callback routine in pfnRxCallback Pointer to reception callback routine Return Values Description Ok Asynchronous initialization successfully done ErrorInvalidParameter pstcMfs NULL pcData NULL pstcMfsInternData NULL Instance could not be resolved 5 20 17 Mfs DC Start Generates an I C start condition Note This function must only be called if the recent MFS instance was initialized to 1 C mode Otherwise the behavior of this function is undefined Fujitsu Semiconductor Europe GmbH 167 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype sm result e Mes 14 Start ellene le Sec mesa e pstel2e Unie SEE u8DestAddress eninfs egdatadirectionitjenneeessy Parameter Name Description in pstcI2c Pointer to MFS instance in u8DestAddress Address of external DC device 7 Bits bit 0
3. Prototype SMS STRESS nose Parameter Name Description lial jose BT instance pointer Return Values Description Ok ERR bit is not set Error ERR bit is set 5 3 13 Bt ReadDataBuffer16 This function reads out the 16 bit PWC result counter if set to 16 Bit mode and clear a possible ERR bit Note This function must be called in the callback function to clear the interrupt request Prototype UHS 6 te Br REA CDA ere SKO sue btn e emeng Parameter Name Description in pstcBt BT instance pointer Return Values Description E E t Recent PWC counter value result 5 3 14 Bt ReadDataBuffer32 This function reads out the 32 bit PWC result counter if set to 32 Bit mode and clear a possible ERR bit Note This function must be called in the callback function to clear the interrupt request Prototype Uime o2 e Be Eeer reet sia laa emeng Parameter Name Description in pstcBt BT instance pointer Return Values Description SE Recent PWC counter value result 5 3 15 Callback0 This function is called if stc bt config t pfnCallbacko is defined and the according interrupt is enabled It is called by IRQ1 Callback Function void CallbackO void Fujitsu Semiconductor Europe GmbH 55 MCU AN 3004 12 E V 14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource D
4. 5 3 2 Bt Init Initializes a BT instance according to its configuration It does not enable the operation Use Bt Enable for enabling a timer after Bt Init Prototype Sm esc Be me Sue brm ic psteBt EEG lo Comrie De omtkc Parameter Name Description in pstcBt BT instance pointer in pstcConfig Pointer to BT instance configuration Return Values Description Ok Initialization successfully done ErrorlInvalidParameter pstcConfig NULL e 32 Bit mode set to odd BT instance number e Other invalid configuration settings Fujitsu Semiconductor Europe GmbH 51 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 3 3 Bt Delnit This function de inits a BT instance Because all Base Timers share one IRQ this interrupt can be disabled by parameter This parameter should be set to TRUE when the last BT instance is de initialized With bDisableBtInterrupts TRUE allshared BT interrupts can be disabled Prototype en resulte t br Delnie ste bua CP SCE boolean t bDisableBtInterrupts Parameter Name Description in pstcBt BT instance pointer in bDisableBt INE SIE SES TRUE All shared BT interrupts are disabled FALSE The interrupt enable is not touched Return Values Description Ok De Initiali
5. FZS FN Et PEE EE After this the user setting 3 user h file is included E OA User Setting Include file Sy ES tine ludeni mus Sees MUS DEE JSE Fujitsu Semiconductor Europe GmbH 25 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 4 L3 Main Files Then the user s device type definition sets the device definition itself ck ck ckock KK AKA ck KA KAZ A K A A A A X AZ kk AXA A K A KAZ A ko A A KA ZAZ ck ko A A KA ZA ck ko AKA A KA ck ko ck ko Sk A ko ck ck Sk ck ko kv ke Sk kk A Ao Global device family definition KCKCKCKCkCkCkCk Ck kk k Ck k Ck k Ck k Ck k Ck KR KK KR KR Ck k Ck Ck kk kk kk Ck Ck KKK Ck kCk KKK KKK k k ck Ck ck k ck k ck k ck ck KK KKK if L3 MCU L3 DEVICE TYPE MB9AF10X define L3 DEVICE MB9AF10X L3 ON else define L3 DEVICE MB9AF10X L3 OFF endif if L3 MCU L3 DEVICE TYPE MB9AF11X define L3 DEVICE MB9AF11X L3 ON else define L3 DEVICE MB9AF11X L3 OFF endif The device type is retrieved from the device definition and the user package definition ck ck ckck ckck AKA ck KA KAZ A K A A A A ZA kk AXA A AZ A kk A ko A A KA ZAZ ck ko A A KA ZA ck ko A ZA A ZA ck ck ck ko Sk A ck ck ck Sk ck ko Sk k k k kk Global device type definition KCKCKCkCkCkCkckCkckCk ck Ck k Ck ck Ck KKK KKK KKK KKK KKK KKK Ck kk KKK KK C
6. Error Handling Write address u32ErrorCode Mfs I2C WriteSync pstcMfs uint8 t amp au8TxBuffer 10 1 if Ok u32ErrorCode Error Handling PEROBCOJE MESE EE pstcecMfssy EEPROM 24C04 I2C SLAVE ADDRESS I2CRead Ok u32ErrorCode Error Handling Read data sequentially u32ErrorCode Mfs I2C ReadSync pstcMfs uint8 t au8RxBuffer 8 if Ok u32ErrorCode Brror Handling S2Rrro5ntode Mrs 2G EM 12CRead i if Ok u32ErrorCode Brror Handling 5 20 35 5 LIN Master communication The following code shows an example of LIN master communication It sends out a master task Lin frame and then a slave task Lin frame Note that an external Lin transceiver is assumed which echoes every transmission Fujitsu Semiconductor Europe GmbH 181 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include mfs h char cRxBuffer 8 Reception Ring Buffer char cTxBuffer 8 Transmission Ring Buffer uint32 t u32CountRxCb void Mfs6LbrCallback void do something void Mfs6RxCallback void u32CountRxCb function Ste amza ia COT ONE S E clam Con fail MFS Lin configuration Ste mesma pstcMfs NULL MFS instance L3 ZERO STRUCT stcLinConfigl char au8RxBuffer 8 char au8TxBuffer 8 uintl6 t ul6Read
7. Prototype SMS STS Z CS SEN OS Sec cem ic OSLCMESDME Parameter Name Description in pstcMfsDnf Pointer to IC auxiliary noise filters Return Values Description Ok All noise filters successfully set ErrorlInvalidParameter e pstcMfsDnf NULL e Wrong enumerator used 5 20 23 Mfs Lin Init For Lin master and slave functionality of an MFS instance Mfs Lin Init must be used instead of Mfs Init Also the Lin configuration has the own type stc mfs lin config t Prototype en vesulrt t Mis biim mmit SLE Westie w7 pstcMfs Conert SS wuss lila Comrie E Se CON Parameter Name Description in pstcMfs Pointer to MFS instance in pstcConfig Pointer to MFS Lin configuration structure Return Values Description Ok MFS Lin initialization successfully done ErrorlInvalidParameter pstcMfs NULL pstcConfig NULL pstcMfsInternData NULL Instance could not be resolved Oneor more configuration data wrong e Wrong enumerator used or enumerator not supported 5 20 24 Mfs_Lin_SetBreak This Function sets a LIN break and break delimiter length with the configuration by the previous initialization Note This function must only be called if the recent MFS instance was initialized to Lin master mode Otherwise the behavior of this function is undefined Fujitsu Semiconductor Europe GmbH 171 MCU AN 300412 E V14 FUJITSU Low Lev
8. 5 10 9 DmaCallback This function is called if stc dma config t pfnCallback is defined and the according interrupt is enabled Callback Function void DmaCallback void 5 10 10 DmaErrorCallback This function is called if stc dma config t pfnErrorCallback is defined and the according interrupt is enabled The argument u8StopStatus contains the stop status error Callback Function void DmaErrorCallback uint8 t u8StopStatus 5 10 11 Example Code Please refer to ADC example in chapter 5 2 16 3 and CRC example in chapter 5 6 8 3 Fujitsu Semiconductor Europe GmbH 105 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 11 DSM Deep Standby Modes Type Definition Configuration Type ste dem contig Address Operator Dsm SetMode sets the deep standby mode according to the configuration defined in a structure type of stc dsm config t The return cause can be retrieved by calling Dem GetReturnCause The return cause is stored in a pointered structure For 8 16 and 32 Bit access to the Backup registers special pointer definitions are defined Notes e The DSM driver does not handle wake up pins which may shared with analog input pins The user has to take care of correct port settings ADE to 0 if wake up input functionality shall be used e Always call Dom GetReturnCause very earl
9. Field Possible Values Description 0 Read Completion interrupt disabled cu R aE 1 Read Completion interrupt enabled m 0 Timer rewrite error interrupt disabled TimeRewriteErrorlrgEn i i Timer rewrite error interrupt enabled ne 0 RTC alarm interrupt disabled Es i RTC alarm interrupt enabled acer 0 RTC timer interrupt disabled Ss 1 RTC timer interrupt enabled RET 0 One hour interrupt disabled ES 1 One hour interrupt enabled 0 One minute interrupt disabled cu M E 1 One minute interrupt enabled n DE EE TN 0 One second interrupt disabled T 1 One second interrupt enabled z 0 Half second interrupt disabled je 1 Half second interrupt enabled 5 25 1 4 RTC Time structure The structure of the type of stc rtc time t has the following fields Type Field Possible Values Description nimes jE u8Second 1 S RTC second uint8 t u8Minute i DY RTC minute uint8 t u8Hour i DE RTC hour uint8 t u8Day 1 31 RTC day mines u8DayOfWeek 0 6 RTC day of week 0 Sunday uint8 t u8Month il 12 RTC month uint8 t u8Year 1 99 2000 RTC year MCU AN 300412 E V14 234 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 25 1 5 RTC Alarm structure The structure of the type of stc rtc alarm t has the following fields Type Field Possible Values Description Wiles i u8AlarmMinute
10. 69 MCU AN 300412 E V14 6 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 5 4 12 Example Code 0000000000000 00000 nenene ana nennen nennen 69 24121 GAN Configuration and KL e E 69 5 4 12 2 Can Initialization and Communiceton eeaeee 71 5 5 CLK Clock Module AMP o T TM 73 5 5 1 Configuration Structure eura tbe teu gege Fea Lo RM EC RR ERA RENE 73 5 5 2 Clk_GetParameters santidad 75 5 5 9 CIK SetDividers A EE 75 5 5 4 CIk SetStabilizationWaitTimes A 76 5 55 Uk WalForManOscllalor iii 76 226 Clk_WaitForSubOscillator im 76 5 5 7 Clk_WaitForPllOscillator AE 77 5 5 0 Uk WartForClockSource Ready sisciicccssncciatcsccancsneddeaexdcosinenndecesdeneauniarns 77 5 59 Clk_MainOscillatorReady cima Aam 77 5 5 10 Clk_SubOscillatorReady d TET 78 5511 Clk PllOsollatorReady E 78 eee MONK S ii p e Em 78 AA EN dj c1 e T 79 5 5 14 Clk_SetMode e EE 79 55 15 Clk_EnableSubClock A EE 79 5 5 16 Clk_DisableSubClock avistamiento 80 5 5 17 Clk_EnableMainClock d D eT 80 5 5 18 Clk_DisableMainClock Numme SR ez da bd ls pada prat peres reis 80 5 5 19 NNN 80 5 5 20 PIlStabilizedCallback e Emm 81 5 5 21 SubClockStabilizedCallback escasa 81 5 5 22 MainClockStabilizedCallback coomcccconnnncccccoonccccccnanaccnnnnnncncnnnann nos 81 ue EE 81 5 5 24 Example Code ni 81 55241 Clock e te lee E 81 95 242 Setting the lora P
11. Parameter Name Description in pstcMft Pointer to MFT instance in pstcFrtOcuConfig Pointer to FRT OCU configuration Return Values Description Ok OCU start stop successfully set ErrorInvalidParameter pstcMft NULL pstcFrtOcuConfig NULL 5 21 8 Mft IcuStartStop Start or Stops ICU operation by configuration The operation of a ICU channel is cotrolled by the en mft icu edge t configurations Prototype en result Mire ICUSceceSeoo Bee mitn ic SES mire LOV COMPLG 1 PSEM pstelcuContag Parameter Name Description in pstcMft Pointer to MFT instance in pstcIcuConfig Pointer to ICU configuration Return Values Description Ok ICU start stop successfully set ErrorlInvalidParameter pstcMft NULL e pstcFrtOcuConfig NULL 5 21 9 Mft IcuRead Reads out the capture count of a ICU channel of an MFT instance Note that 0 is returned if pstMft NULL and u8IcuChannel gt 3 and does not mean the counter value 0 MCU AN 300412 E V14 202 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype wines 16 lacio e Mie ICURSAC SEC meet E pstcMft u8IcuChannel Parameter Name Description in pstcMft Pointer to MFT instance in u8FrtChannel 0 1 2 meaning ICUO 1 2 Return Values Description 0 pstcMft NULL e Wrong ICU
12. bOccp2Buf1 bOccp3Buf1 bOccp4BufT bOccp5Buf1 bMod0 bMod1 bMod2 bMod3 bMod4 bMod5 ul60cu0CompareValue ul60culCompareValue ul60cu2CompareValue ul60cu3CompareValue ul60cu4CompareValue ul60cu5CompareValue pfnFrtOPeakCallback pfnFrtlPeakCallback pfnFrt2PeakCallback p nFrt0ZeroCallback pfnFrtlzeroCallback pfnFrt2ZeroCallback pfnOcu0Callback pfnOculCallback pfnOcu2Callbac pfnOcu3Callbac pfnOcu4Callbac pfnOcu5Callbac S S U Ei S U Ei S U Ei U Hi So U Hi So U Ei U ti U S S U Ei S U Hi 5 U Ei U Ei S U Ei U se Ei U 0x0400 0x0500 0x0600 0x0700 0x0800 0x0900 N D N D KES Mie ESEC MECA EEN eMETO MFT instance amp stcMftFrtOcuConfig ERTSOCU Configuration NUL WFG configuration NUL NZCL configuration NUL ICU configuration NUL ADCMP configuration NUL PPG configuration PSECMEE Site men yes e METUO Setup pointer to MFTO instance Mft FrtStart pstcMft TRUI TRUI TRUI Starts ERTO Start FRI Start ERDZ s EN ENE lt 5 21 28 2 FRT Operation with OCU Output Dead Time Insertion and PPG Modulation This code shows how to initialize a WFG OCU with WFG dead time insertion and PPG modulation The RTOn ports show the same signals but with diffe
13. endif DT and QPRC have shared ISR elif L3 PERIPHERAL ENABLE QPRCO L3 ON L3 PERIPHERAL ENABLE QPRC1 L3 ON amp amp V L3 PERIPHERAL ENABLE DTO L3 ON void DT Handler void iE FM3 DTIM TIMERIRIS f TIMERXRIS 1 FM3 DTIM gt TIMER2RIS f TIMERXRIS 1 DtIrqHandlerO stc dtn t amp DTO amp m_astcDtInstanceDataLut DtInstanceIndexDt0 stcInternData if L3 PERIPHERAL ENABLE QPRCO L3 ON if FM3_INTREQ gt IRQ06MON amp IRO06MON QPRCO BITMASK 1 2 0 OprcIrqHandler stc qprcn t amp OPRCO amp m astcOprcInstanceDataLut QprcInstanceIndexQprc0 stcInternData tendif dif L3 PERIPHERAL ENABLE QPRC1 L3 ON itf FM3 INTREQ gt IRQ06MON amp IRO06MON QPRC1 BITMASK 1 2 0 QprcIrqHandler stc qpren t amp QPRC1 amp m astcOprcInstanceDataLut QprcInstanceIndexOprc0 stcInternData tendif tendif O Fujitsu Semiconductor Europe GmbH 33 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 4 L3 Main Files For problems which may occur at compile time in interrupts c please also read the hints in chapter 6 3 Also refer to supported interrupt types described in chapter 6 4 4 6 File interrupts h This header module includes the resource s header files to collect the interrupt service routines prototypes Additionally it defines some needed IRQMON bit masks for shared interrupt vectors 4 7 File ramcode c This mo
14. psreebe NUL 5 6 4 Crc Push8 Push 8 bit integer data to a CRC module with if no DMA is used Prototype SMS SOE sue cuca ue perece Or he u8DataToPush Parameter Name Description kmnfpeseteere CRC instance pointer in u8DataToPush 8 Bit data to be pushed to CRC Return Values Description Ok De Initialization of CRC module successfully done nvalidParameter He GOE josncebe NUM 5 6 5 Crc Push16 Push 16 bit integer data to a CRC module with if no DMA is used Prototype en result t Cre Pushl sue Cren ue SCC EE ul6DataToPush Parameter Name Description ia psueciea CRC instance pointer in ul6DataToPush 16 Bit data to be pushed to CRC Return Values Description Ok De Initialization of CRC module successfully done nvalidParameter Error E lios SENT Fujitsu Semiconductor Europe GmbH 87 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 6 6 Crc Push32 Push 16 bit integer data to a CRC module with if no DMA is used Prototype SMS STK Cia Est see Crem Se CC Danes ic u32DataToPush Parameter Name Description la psteCre CRC instance pointer in u32DataToPush 32 Bit data to be pushed to CRC Return Values Description Ok De Initialization of CRC module successfully
15. Configuration Type stc wdg config t Address Operator Both the Hardware and Software Watchdog use the same configuration structure Both have dedicated interrupt callback functions in which the user has to feed the corresponding Watchdog For the Software Watchdog Wdg InitSWdg is used for setting the interval time Oo FeedSwWdg resets the Watchdog timer by a function call dg QuickFeedSwWdg does the same but the code is inline expanded for e g time critical polling loops Oo InitHwWdg sets the Hardware Watchdog interval Wdg DisableHwWdg disables the Watchdog if 2 magic words as parameters are used Wdg FeedHwWdg and Oo QuickFeedHwWdg do the same as their correspondig functions for the Software Watchdog but here are two parameter needed the 2 one the inverted value of the st Note e The Hardware Watchdog shares its interrupt vector with the NMI Therefore use the stc wdg config t bTouchNVIC configuration whether to touch the NMI HWWdg NVIC registers in Wdg InitHwWdg Wdg DisableHwWdg or not The Hardware Watchdog is also switched off in System Init in system mb9 ab xyz c Set the definition for HWWD DISABLE to 0 in system mb9 ab xyz h for letting the Hardware Watchdog running during start up phase 5 28 1 Configuration Structure Both Wardware and Software Watchdog have the following configuration structure of the type of stc wdg config
16. Flashtiming SetFlashWait FlashOCycleMode function4 Device Types 4 5 Flashtiming SetWorkFlashWait WorkFlashOCycleMode MCU AN 300412 E V14 146 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 18 GPIO General Purpose I O Ports Type Definition Configuration Type Address Operator The GPIO modules only consist of header files for each device The naming is gpio mb9 ab f O 9AB O 9AB x klmnst h These particular header files are included in the common header file gpio1pin h which takes care of the device and package These particular header files consist of two block for each functional pin There are definitions of pseudo functions for Set port pins e Set resource pins inclusive relocation Attention e Carefully adjust your device and package described in chapter 4 4 Wrong pin usage may be caused if the device and package is set wrongly e f External Bus Interface pins with prefix 1 are provided by the package the user must set the UERLC bit of EPFR11 manually It can be done by the following instruction EPFRi1 UI e Carefully check in device documentation whether SOUBOUT pin at SOUBOUT n or TIOBO pin should be output TTOBO SUBOUT is not provided by this driver Internal LSYN connection is not provided by this driver
17. Since L3 version 1 1 only Adc Init need a pointer to the user configuration stc adc config t 5 2 1 Interrupt Scan Conversion If the scan conversion only and interrupt method is enabled the conversion of several channels are stored in own buffers These buffers will have all the same size An end notification is available via stc adc config t pfnCallback or in erroneous case Fujitsu Semiconductor Europe GmbH 37 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API stc adc config t pfnErrorCallback is called when the buffers are filled or an error occurred The ADC driver takes care of the FIFO fill level according to the data left to be stored and the number of the channels FIFO depth 16 UJ gt O a o UOHOSIIP 1114 UJ c gt ka O gt N Callback function Figure 5 1 Example ADC Interrupt Scan Conversion Assume channel 2 and 5 are selected for 8 Bit conversion The buffer sizes may be 10 bytes for each channel which means 20 conversions overall In this case the starting FIFO depth is set to maximum i e 16 which means 8 conversions for each of the two channels After these 16 conversions the ADC driver gets the first interrupt and fills the buffers with 8 bytes each according to the channel information Then the driver updates the buffer pointer and calculates 2 bytes left for each channel Then the FIFO depth is set to 4
18. y ul6ReturnCause 0 Dam SetMode amp ul6ReturnCause if 1 stcReturnCause InitxReset MCU AN 300412 E V14 110 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 12 DT Dual Timer Type Definition SEG Gjem i Configuration Type sce dre ODE Address Operator DTO Dt_Init must be used for activation of the internal data structures for using the Dual Timer DT Here the interrupt callback functions for each of the 2 channels are set up Because the DT has no output pins its interrupt service is always used For configuration of a DT channel a structure with the type stc dt channel config t has to be used After configuration the DT channel can be set up by Dt SetChannelConfig A DT Channel can be enabled by the function Dr EnableChannel Depending on the used mode it is started in Free run mode e Periodic mode e Single shot mode With Dt WriteLoadChannel the recent DT counter is set to the value given in the configuration stc dt channel config t u32DtLoad This works in each of the three operation modes With Dt WriteBgLoadChannel the background reload value can be set which is then set to the load value after the DT counter reaches the next O Before deinitialization of the DT by Dt DeInit it is recommended to disable all channels via DE DisableChannel before to avoid a possible unwanted
19. 3 z 3 2 stcCrcConfig bUseDma TRUE DMA used TENOR rense st cec EE SSteS mee nfi Setup DMA tcCrcDmaConfig bEnable OF Z Ouse init DMA first tcCrcDmaConfig bPause 0 tcCrcDmaConfig bSoftwareTrigger FALSE Ku Si init DMA first tcCrcDmaConfig enDmaIdrq Software Software DMA trig tcCrcDmaConfig u8DmaChannel 0 tcCrcDmaConfig u8BlockCount 0 tcCrcDmaConfig ul6TransferCount 63 u32ConstData size 1 tcCrcDmaConfig enTransferMode DmaBurstTransfer tcCrcDmaConfig enTransferWdith Dma32Bit tcCrcDmaConfig u32SourceAddress uint32 t amp cu32ConstData tcCrcDmaConfig u32DestinationAddress uint32 t amp FM3 CRC gt CRCIN tcCrcDmaConfig bFixedSource FALSE tcCrcDmaConfig bFixedDestination TRUE tcCrcDmaConfig bReloadCount FALSI tcCrcDmaConfig bReloadSource FALSE tcCrcDmaConfig bReloadDestination FALSI tcCrcDmaConfig bErrorInterruptEnable TRUE tcCrcDmaConfig bCompletionInterruptEnable tcCrcDmaConfig bEnableBitMask FAL tcCrcDmaConfig pfnCallback amp Crc DmaFinished tcCrcDmaConfig pfnErrorCallback amp Crc DmaError OE aO odo ORO OE OO AE AG EU OV L Dma Init Channel amp stcCrcDmaConfig Dma Enable stcCrcDmaConfig bEnable 1 Now enable DMA stcCrcDmaConfig bPause 0 stcCrcDmaConfig bSoftwareTrigger E Prepare software trigger MCU AN 300412 E V14 90 Fujitsu Semiconductor
20. 5 18 1 Gpio1pin Initln This macro sets a Port to digital input Macro cto lua Imilcila a Sseuelags Parameter Name Description Port Pin Name p GPIOIPIN Pxy normal logic GPIO1PIN PNxy inverted logic settings SS a Gprelpin Inve eu lihie Pull up 0 OFF 1 ON Fujitsu Semiconductor Europe GmbH 147 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 18 2 Gpio1pin InitOut This macro sets a Port to digital output Macro Gorolpin mmitte jo Ssrrings Parameter Name Description Port Pin Name p GPIOIPIN Pxy normal logic GPIO1PIN PNxy inverted logic settings SSES A Gpiolpin InitVal Initial value 0 or 1 5 18 3 Gpio1pin Get This macro reads out a GPIO pin via PDIR Macro Gpiolpin Get p Parameter Name Description Port Pin Name p GPIOUP IN Pxy normal logic GPIO1PIN PNxy inverted logic 5 18 4 Gpio1pin Put This macro set a GPIO port via PDOR Macro Eiere bet EUC S VA Parameter Name Description Port Pin Name p GPIO1PIN Pxy normal logic GPIO1PIN PNxy inverted logic Value b Gpre lean unaven Initial value 0 or 1 5 18 5 SetPinFunc_PINNAME This macro sets the pin function to peripheral usage and
21. Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 2 L3 Structure e Ifa resource is not used by no activation in 3 user h its driver code is not compiled and linked regardless of the driver module is being a member of the project workspace 2 3 Graphical Example The following graphic illustrates a driver for resource A Ra which has 2 active instances Main Application Configuration Resource A Instance 1 Configuration Resource A Instance 0 Instance 1 Intern Data Stc ra intern data t pstcRalnternData a lt c bal i un a lt o o i gt o W c Instance 0 Intern Data Stc ra intern data t pstcRalntermDatad Hardware Resource A Instance 1 Stc ran t pstcRa Hardware TESTIS A Instance 0 ste ran t pstcRa Figure 2 1 Resource Driver Structure Example Fujitsu Semiconductor Europe GmbH 19 MCU AN 300412 E V14 Low Level Library Manual FUJ ITSU Chapter 2 L3 Structure 2 4 Interrupt Flow The following flow shows how interrupts are handled in the L3 Application ISR Callback interrupts C ResourceName c Interrupted Name Handler void NamelrgHandler stc Namen t amp Name amp m astcNameInstanceDataLut V NameInstanceIndexName X StcInernData pstcNameInternData gt pfnCallbackName l l NameCallbackFunction Return Return Resume Figure 2 2 Interrupt and Callback Flow Di
22. L3 PACKAGE L3 DEVICE PACKAGE define L3 DEVICE TYPE L3 TYPEO felse error Device Type not defined endif 3 3 Enable Peripherals For using certain drivers enable the peripherals in 3_user h as described in 4 4 2 and 4 4 4 This adjustment is mandatory because it controls whether a driver module has to be compiled or not Carefully check the activation before usage whether your device supports a peripheral and especially a certain instance 3 4 Setting Interrupt Levels Finally define the interrupt levels as described in 4 4 5 3 5 Combination of Drivers Some settings of the resource configuration requires to activate an additional driver module such as external interrupts or DMA usage In this case the user has to do this manually in I3 user h and has to define the configuration and has to take care of correct initialization of all drivers in his application 3 5 1 Example ADC and DMA In this case the ADC has to be initialized and configured for DMA transfer The user also has to activate manually the DMA module and to configure a desired channel to be used The ADC driver relies on the proper DMA configuration Fujitsu Semiconductor Europe GmbH 23 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 4 L3 Main Files 4 L3 Main Files DESCRIPTIONS OF THE MAIN L3 MODULES 4 1 File base types I3 h In the base t
23. Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype en result t Rtc EnableDisableAlarmRegisters volatile stc rtcn t pstcRtc Sus EE pPsite conti Gay Parameter Name Description in pstcRtc RTC instance pointer in out pstcConfig Pointer to RTC configuration structure Return Value Description Ok Date and time updated in configuration ErrorlInvalidParameter pstcRtc NULL e pstcConfig NULL ErrorTimeout Polling loop has timed out 5 25 10 Rtc_RequestDateTime This function requests a copy of the recent time to the RTC registers In the RTC ISR the callback function stc rtc config t pfnReadCallback with all its 7 arguments for date and time is called Note This function needs the INTCR E bit Read Completion Interrupt Enable set to 1 by Rtc Init orRtc EnableDisableInterrupts Prototype enamel it EE e REUE SE Darem volatile Ee Parameter Name Description Emo SIEG EIC RTC instance pointer Return Value Description Ok Request started ErrorlInvalidParameter pstcRtc NULL ErrorNotReady A previous request was not finished 5 25 11 Rtc_StatusRead This function provides the enumerated status en rtc clock status t of the WTCLKM register Prototype Sul rte Clock srerts t Rua SeaicwisiNsercl volatile
24. x Ei pd pd Bd Dd oe X a p Fh U A p a Extif InitArea 1 amp stcExtIF ES uintl6 t EXTIF ADDRESS 0x1234 First memory address ul6SramTest uintl6 t EXTIF ADDRESS Read back if ul6SramTest 0x1234 i Error handling Extif DeInitArea 1 Fujitsu Semiconductor Europe GmbH 129 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 15 9 2 NAND Flash The following code excerpt shows how to use the EXTIF functions for NAND Flash connected to chips select 0 include extif define EXTIF NAND ADDRESS 0x60000000 External NAND Flash connected to CSO define EXTIF AREA 0 NAND Flash commands define NAN BADO define EAD1 define AGEPROG define EADOOB define ERASE1 define STATUS define EQIN define EADID define EADID1 define ERASE2 define ESET Es z R R P R z z z z ees ea E z z z is dez dez bis seo tel le uo qo ere oie ele ley odes slo leo SES EE EE RER Z D z define define LASH OK ASH ERROR p z S bea es Helper functions static void Extif Wait volatile uint32 t u32Count while u32Count static void Nand Reset void Extif Nand SetCommand EXTIF
25. 0x4003590F 3 c c c 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 Y UJ UU UU UJ UJ UU UJ UJ UU UU UJ UU UU UJ D c 16 Bi define define define define define define define define 0x40035900 0x40035902 0x40035904 0x40035906 0x40035908 0x4003590AU1 0x4003590C 0x4003590E volatile uintl6 t volatile uintl6 t volatile uintl6 t volatile uintl6 t volatile uintl6 t volatile uintl6 t volatile uintl6 t volatile uintl6 t UJ UJ UU UU UJ UJ UU UJ EK GK a GK e V ee Cr 32 Bi define R01020304 define R05060708 define R09101112 define R13141516 volatile uint32 t volatile uint32 t volatile uint32 t volatile uint32 t 0x40035900U1 0x40035904U1 0x40035908U1 0x4003590CU1 f CH EK 5 11 4 Dsm_SetMode This function sets the Deep Standby STOP or RTC mode The pin state defined by stc dam config t bLpmPortHiZState is also set Prototype emn resule t Dem S Ye MO ele lstre cem Contig t TEE ber Parameter Name Description Eet EE EE Pointer to DSM configuration structure Return Values Description Ok Successfully returned ErrorInvalidParameter pstcConfig NULL e Ilegal Mode Note if the hook function pointer is given unequal NULL this user function is ca
26. 4 3 1 L3 ZERO STRUCT Some compilers e g GCC do not accept a structure zero initialization like StcaESomesttuct t YD ote gt ome EE e NE IAR and KEIL compilers throw a warning if the first structure element is an enume type but those compilers automatically include the library function eabi memclr4 to clear the structure For this reason the string library s memset was introduced and used for the macro L3 ZERO STRUCT string h is included by 3 h fdefine L3 ZERO STRUCT x memset amp x 0 sizeof x The zero initialization then is done like L3 ZERO STRUCT stcSomeStructure Fujitsu Semiconductor Europe GmbH 27 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 4 L3 Main Files 4 4 File 13 user h This file is the most important file for user settings of the L3 It controls every activation of the resource drivers and its instances Be aware that these activations control the compile process via the preprocessor Also the interrupt service routines are dependent on this activations Attention The adjustments in this chapter do not set the used IDE environment settings or options Make sure that the used device the provided tool s Flash programming tool and the linker settings are properly adjusted to the device which is defined in I3 user h 4 4 1 Device Definition The device definition macro is L3 MCU and the device name is checked in 3 h Ck
27. Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Address boolean t bFixedSource 1s Source address fixed FALS Source address increase eee bFixed TRUE Destination address fixed pi Destination FALSE Destin address increase TRUE Reload Count at end boolean t bReloadCount d FALS Stop DMA at transfer end bReload TRUE Reload source address boolean t Source FALSE Do not reload source PRO nee bReload TRUE Reload destination address A Destination FALSE Do not reload destination y pace TRUE Interrupt at error of DMA boolean t Tire TS em FALSE No int t Pablo SE o interrup bc letion harc meya Interrupt at end of DMA boolean t Interrupt FALSE No int t Enable SE o interrup bEnableBit TRUE Clear EB at end of DMA boolean t S Mask FALSE Do not clear EB at end TUNG PET IC pfnCallback Completion bee DD function pointer css otr arol RBL x Error callback function PTE FIF Callback pointer WG HEROS EOR uint8 t Em Error code from stop status 5 10 2 Dma Init Channel Sets up an DMA channel without starting immediate DMA transfer Enable Dma Channel is used for starting DMA transfer Prototype enes SUM e Dua ale MAS volarcile sue ele comerlo 1 Seco Parameter Name Description in pstc
28. Lvd nYrtrr Lvd De q nit Type Definition Configuration Type sis lyd config te Address Operator called if its pointer NULL 5 19 1 Configuration Structure The LVD module uses the following configuration structure of the type stc 1vd config t initializes the LVD interrupt with the given voltage threshold and rq disables the LVD interrupt In case of an interrupt a callback function is Possible eee Type Field Description yp Values p en lvd irg voltage t enIrgVoltage see below Threshold Voltage for Interrupt en lvd res voltage t enResVoltage see below Threshold Voltage for Reset TRUE LVD Reset enabled b i ie E e oolean bEnableLvdReset FALSE LVD Reset disabled EN ERU 4 LVD Interrupt callback function pointer Only available for Device Type 3 6 7 5 19 1 1 Interrupt Voltage Enumerators The following enumerators are used for en 1vd irq voltage t enIrqVoltage There are existing 3 configuration types A Device Type 0 1 2 4 5 B Device Type 3 7 C Device Type 6 Enumerator Description Configuration Type DvdIrgVoltagel70 Interrupt voltage in the vivinity of 1 70 Volts C LvdIrqVoltagel75 Interrupt voltage in the vivinity of 1 75 Volts C LvdirqVoltage180
29. OprcPcMode3 OprcRcMode2 switched off anyhow TRU TRUE TRU TRUE TRU TRUE EnablePcMatchRcMatchInterupt EnablePcMatchInterrupt bEnableCountInversionInterrup pfnCountInversionCallback pfnZeroIndexCallback pfnOverflowCallback pfnUnderflowCallback pfnRcMatchCallback pfnPcMatchCallback pfnPcMatchRcMatchCallback pfnOutrangeCallback bTouchNVIC Ed Ed Ed Ed il verflowCallback nderflowCallback a C ZZ Z z e mut E Take care of DT amp stcOprcConfig MCU AN 300412 E V14 226 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API psteopre ste gpren Es amp OPRGCO Opre Enable pstcOprc while 1 u8PosCount Opre GetPositionCount pstcQprc u8RevCount Opre GetRevolutionCount pstcQprc Display u8PosCount as one s digit Display u8RevCount as ten s digit Fujitsu Semiconductor Europe GmbH 227 MCU AN 3004 12 E V 14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 23 RAMCODE RAM Code Type Definition Configuration Type Address Operator This driver module does not support any API function for the user Nevertheless it is used by the FLASH driver module and thus contains the low level Flash erase and programming routines Because this routines use
30. Output FALSE Output level normal boolean t bInverted TRUE Output level inverted E om FALSE Output level normal boolean t Qui c TIRS Trigger input level inverted Taput FALSE Trigger input normal MCU AN 300412 E V14 198 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 21 2 Mft Init This function initializes an MFT instance with the given configurations At least the FRT OCU configuration of the type stc mft frt ocu config t must be egal and its pointer unegual to NULL Not used parts of the MFT can be stated by NULL pointer to its configurations Prototype Sm resule tc Mice tale SEC imeem E pstcMft SES ita see CUC OT O ET EE Er EOC CONE SEC met WEG COMEL le pstcWfgConfig SES mie mel Come 15 pstcNzclConfig SEC mite Gu Comba E7 pstereuConfig SEC met eet es pstcAdcmpConfig SEE milde DOG CONTIG E pstcPpgConfig Parameter Name Description in pstcMft Pointer to MFT instance n i Pointer to FRT and OCU configuration structure kro enee Eeer flg a o This configuration is mandatory ee Pointer to WFG configuration structure This pointer in pstcWfgConfig can be NULL SEN i Pointer to NZCL configuration structure This pointer ia ES BENZ ed C one can be NULL E Pointer to ICU configuration structure This pointer in pstcIcuConfig can
31. QPRC instance pointer 5 22 5 Qprc Disable This functions disables QPRC counting MCU AN 300412 E V14 220 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype NZOHCNO CDA SSME Parameter Name Description in pstcQpre QPRC instance pointer 5 22 6 Qprc SetPositionCount Sets a new Position Count value Prototype Void O DEC C BoSt oOnCouUnc MSc Dc C VUELO e ul6PcValue Parameter Name Description in pstcQpre QPRC instance pointer in ul6PcValue New position count value 5 22 7 Qprc SetRevolutionCount Sets a new Revolution Count value Prototype Void Qore SouNnevolwelomCouine MACH cabane e ul6RcValue Parameter Name Description in pstcQpre QPRC instance pointer in ul6RcValue New revolution count value 5 22 8 Qprc_SetRevolutionCountCompare Sets a new Revolution Count Compare value Prototype VOL Gore sci RevolitdomeourtGConpamtc Sre Goren e Sic OT uintl6 t u16RcCompValue Parameter Name Description in pstcQpre QPRC instance pointer in ul6RcCompValue New revolution count compare value 5 22 9 Qprc SetPositionRevolutionCountCompare Sets a new Position and Revolution Count Compare value Prototype void Qprc SetPositionRevolutionCountCompare stc qprcn t pstcOprc uintl6 t ul6PcRcC
32. amp CANO tcCanConfig pfnStatusCallback tcCanConfig pfnErrorCallback pstcMsgBufferl pstcMsgBuffer2 site cancon tiq stcMsgData stcMsgId stcMsgBufferl stcMsgBuffer2 ID Mask ID Mask Set Set Set CAN amp stcMsgId amp stcMsgData Message Message CO BLGUT AFO message message message message data ID buffer 1 buffer 2 CAN instance pointer Message ID pointer Message Data pointer Message Buffer 1 pointer Message Buffer 2 pointer for message 1 for message 2 instance 0 ID pointer Data pointer DEL SEE amp stcMsgBufferl amp stcMsgBuffer2 Messag Buffer 1 pointer can status Messag Buffer 2 pointer chge Bunce per se iCanStatuseh can error func ptr t CanErrorCb DisableAutomaticRetransmission tcBitrate u8TimeSegmentl tcBitrate u8TimeSegment2 tcBitrate u8SyncJumpWidth tcBitrate ul6Prescaler data nCanPrescaler CanPreDiv15 TRUE 80 MHz 5 16 Mhz tcBitrat settings sgId u32Identifier sgId bExtended tcMsgData u8DataLengthCode no special values Data 0x70 Data 0x61 Data 0x52 Data 0x43 Data 0x34 Data 0x25 Data 0x16 I Oy O 1460 R Ee stcMsgBufferl stcIdentifier u32Identifier sgBufferl stcIdentifier bExtended FALSE 0x00000000 Data 0x07 settings just random assumed auto response from other CAN n
33. tcAdcConfig0 pu8ChannelBufferPointer 0 au8AdcBufferCh0 tcAdcConfig0 ul6ChannelBufferCounter 0 Init buffer counter tcAdcConfig0 ul6ChannelBufferEndCount BUFFER8SIZE Set buffer end tcAdcConfig0 enUseInterruptsDma AdcPolling Sampling Time 9 4 1 37 cycles gt 25 ns cycle 37 cycles 925 ns tcAdcConfig0 u8SamplingTime 9 tcAdcConfig0 enSamplingTimeMultiplier AdcSamplingTimeMultiplier4 Comparison cycles Divider 5 gt 25 ns cyole 525 ns gt A 125 ns 14 1750 ns overall comparison time TYPEO device stcAdcConfig0 u8ComparisonTimeDivider 5 if Ok Adc Init stc aden t amp ADCO amp stcAdcConfigO0 pstcAdcO stc adcn t sADCO for u8Counter 0 u8Counter lt BUFF E u8Counter Adc TriggerStart pstcAdc0 while Ok Adc ConversionStatus pstcAdc0 BO UAE Adc StoreData pstcAdcO0 5 2 16 2 Interrupt Mode 8 Bit The following code shows how to use the ADC in interrupt mode using 8 Bit conversion Fujitsu Semiconductor Europe GmbH 45 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include adc h define BUFFER8SIZE 16 uint8 t u8ConversionDone 0 void Adc Callback void u8ConversionDone 1 void Adc ErrorCallback void Do something function sueca denia pstcAdcO NULL stc adc config t stcAdcConfig0 uint8
34. 0 reception data Write data to EEPROM generate start condition u32ErrorCode Mfs I2C Start pstcMfs EEPROM 24C04 I2C SLAV ESS T20Write Ok u32ErrorCode Error Handling Write data to EEPROM data write u32ErrorCode Mfs I2C WriteSync pstcMfs uint8 t au8TxBuffer 2 if Ok u32ErrorCode Error Handling Write data to EEPROM generate stop condition u32ErrorCode Mts I2C Stop pstcMfs I2CWrite if Ok u32ErrorCode H Error Handi ing Fujitsu Semiconductor Europe GmbH 179 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API MfsWait 400000 Give EEPROM 10ms time for writing data internally Hil No read access is allowed in this time Step 2 Read back data from EEPROM u32ErrorCode Mfs I2C Start pstcMfs EPROM 24C04 I2C SLAV Ro SUI Wise Ok u32ErrorCode Error Handling u32ErrorCode Mfs I2C WriteSync pstcMfs uint8 t au8TxBuffer 1 if Ok u32ErrorCode Error Handling ErrorCode Mfs I2C Continue pstcMfs EPROM 24C04 I2C SLAVI ESS I2CRead Ok u32ErrorCode Error Handling u32ErrorCode Mfs I2C ReadSync pstcMfs uint8 t au8RxBuffer if Ok u32ErrorC
35. 0 to GE L3 NO FLASH RAMCODE L3 ON and address not within Work Flash memory area 5 16 7 Example Code The following code excerpt shows how to use the FLASH functions Fujitsu Semiconductor Europe GmbH 139 MCU AN 300412 E V14 FUJITSU Low Level Library Manual J Chapter 5 L3 Resource Driver API 5 16 7 1 Devices with Single Flash include flash h function uint8 t au8FlashPattern 8 0 1 2 3 4 5 6 7 uintl6 t aul6FlashPattern 4 HOSA Sia Ose 81503056 015067 1I Erase Sector SA6 SAV Flash Erase 0x4000 Flash Erase 0x4004 Program 16 bit word to 0x4000 Flash Writel6 0x4000 0x1234 Write even then odd address Flash Write8 0x4004 0x55 Flash Write8 0x4005 OxAA Writ ven address even of data Flash WriteBlock8 0x4008 au8FlashPat WP Write even address odd of data Flash WriteBlock8 0x4010 au8FlashPat Write odd address even of data Flash WriteBlock8 0x401D au8FlashPatt Write odd address odd of data Flash WriteBlock8 0x4025 au8FlashPat SJ Write Flash WriteBlockl6 Flash WriteBlock16 0x4030 aul6FlashPattern 3 MCU AN 300412 E V14 140 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 16 7 2 Devices with Work Flash finciude flash h function uint8 t au8FlashPattern 8 0 1 2 3 4 5 6 7 uintl6 t aul6Flash
36. 1 59 Alarm minute Uae i u8AlarmHour il gt 23 Alarm hour ber E u8AlarmDay LU eer S Alarm day uba je u8AlarmMonth 1 12 Alarm month uint8 t u8AlarmYear i SEL E 2 0 0 0 Alarm year 5 25 1 6 RTC Timer Configuration The RTC s timer configuration of the type of stc rtc timer config t has the following structure Type Field Possible Values Description Gint E u32TimerValue 18 Bit value for RTC Timer bTi m niu TRUE Timer set to count interval mode boolean t Interval Se FALSE Timer set to one shot mode 5 25 2 RTC Definitions For the Month and Day of the Week values rtc h provides defintions as shown below Also the year can be stated as YYYY format by using Rtc Year macro Fujitsu Semiconductor Europe GmbH 235 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API ck ck ckck ckck kk ck ck KA KAZ A K A A A A XK kk AXA A KZ A KAZ A X A A KA ZAZ ck ko A A KA ZA ck ko ck ko A A ck ck ck ko ck ko Sk A ko ck ck Sk ck ko Sk k A ko ko A ko brief Year calculation macro for adjusting RTC year format KCKCKCKCkCkCk kk kCkCk Ck k kCk Ck k k Ck Ck kCkCk Ck k Ck kCk Ck k Ck Ck Ck kCk Ck k kCk Ck kCkCk Ck Ck kCk k Ck kCk Ck kCkCk Ck Ck k ck k ck k ck k ck k ck ck kckckckckok define Rtc Year a a 2000 ede e ce he eee heec e cec ce ec e eee e esee e ce e cene cec ec ec ke ce eee ce cce ec ecce ee ecc kc ec
37. 5 25 1 3 RTC Interrupts Enable Strucutre 234 229 14 FIG Time SUC tm 234 5 25 1 5 RTC Alarm structure eee 235 5 25 1 6 RTC Timer Gon GuOFi us ceci ancient DR ERE e trei he brane 235 5 292 A T a 235 5 25 9 Ric Ini 237 A mms 237 50 25 35 F SetDate Kit E 238 5255 Ric Seiler ate FMS susan pitiriasis 238 5 25 7 Ric E REENEN 238 5 25 8 Rtc EnableisableAlarmbegtsterst 239 5 25 9 Ric ReadDaleTimeaPolliFig sica rt dx Recap cas 239 5 25 10 Ric RequesiDateTimb soii da 240 5 25 11 Rio SIISE sn di ean ss pE tni Ra 240 9 29 12 Re ESA AAA PP a AA 241 5 25 13 RE TE SEN i eM METTE 241 5 25 14 A TS SOON NR D 241 5 25 15 Rtc_TimerStatusRead oru istius a 241 MCU AN 300412 E V14 14 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 52516 Rtc_GetRawTime EEN 242 5 25 17 R A 242 SN NEIGE NEL PEE 242 5 25 19 ReadCallback EE 243 525 20 AlatmiGallback m 243 5 25 21 A DAG AP A 243 5 25 22 HalfSecondCallback E 244 5 25 23 OneSecondCallback EEN 244 5 25 24 OneMinuteCallback mec E 244 5 25 25 OneHourCallback ME 244 5 25 26 Example Codes sese nnns 244 JR n A RA ARRETE RN ES 244 55 202 RTC TimMer suspiros 246 5 20 USB USB Host and USB Device uie csi ideada 248 5 27 WC Watch IN i m 249 5 27 1 Configuration Structure Pee 249 5 2 2 WCE DE US TNNT ad EE E TT 250 5 27 3 Wc Init 250 Sel RS Nm 250 A stE 251 Wed W
38. Stop PPG4 i id FALSE Preserve PPG4 operation state Return Values Description Ok Dedicated PPGs stopped ErrorInvalidParameter pstcMft NULL pstcMfsInternData NULL Instance could not be resolved Intance number of internal data out of range corrupted 5 21 12 Mft PpgTimerStart Start all 3 PPG timer counters of an MFT instance by Software Start PPG0 2 4 PPG8 10 12 timer synchronously Prototype sm result Mre PogtuerSrare ste mien es PECENE Parameter Name Description in pstcMft Pointer to MFT instance Return Values Description Ok All PPGs started ErrorInvalidParameter pstcMft NULL pstcMfsInternData NULL Instance could not be resolved Intance number of internal data out of range corrupted MCU AN 300412 E V14 204 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 21 13 Mft PpgTimerStop Stop dedicated PPG timer counters of an MFT instance by Software Start synchronously Stop PPG0 2 4 PPG8 10 12 timer individually Prototype SMS STU EEN EO CHM een Ses mien es boolean t boolean t boolean t pstcMft bPpg0 bPpg2 bPpg4 Parameter Name Description in pstcMft Pointer to MFT instance RUE TRUE Stop PPGO B3 FALSE Preserve PPGO operation state UT m TRU
39. The Ethernet Driver is used as a low level driver for FM3 devices It is available as a stand alone version or integrated within the FM3 Low Level Library LLL This is the user manual e AN706 00066 1v0 E This AppNote gives background information about the Ethernet Switch code example Fujitsu Semiconductor Europe GmbH 119 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 14 EXINT External Interrupts and NMI Type Definition Configuration Type stc exint config t Address Operator With Exint Init the external interrupts are enabled as given in the configuration Note that both external interrupt groups 0 7 and 8 15 can be enabled individually If a single channel may be disabled and re enabled during runtime the functions Exint DisableChannel andExint EnableChannel can be used The external interrupts are disabled globally by Exint DeInit Each channel provides an individually callback function which is handled in the interrupt service routine Exint Nmi Init initializes the None Maskable Interrupt which means that the callback function is set to the dedicated internal data and if set by stc exint nmi config t bTouchNVIC the NVIC is initialized Exint Nmi DeInit resets the NVIC depending on the setting in stc exint nmi config t bTouchNVIC Note The NMI sha
40. This function initializes the BT I O Selectors by their configuration Prototype SMS STU CEB Ege EOS KedL Sc o SscAkc om csc Coney Parameter Name Description in pstcConfig Pointer to BT IOSEL configuration structure Return Values Description Ok Initialization successfully done nvalidParameter accio e pstcConfig NULL Other invalid configuration settings 5 3 9 Bt DelnitloSel This function de initializes one or more BT I O Selectors by their configuration Prototype Sm result t Be DernitIrosel Swe lo losel conirile 1 sec one Parameter Name Description in pstcConfig Pointer to BT IOSEL configuration structure Return Values Description Ok De Initialization successfully done nvalidParameter BITTE COSTS e pstcConfig NULL Other invalid configuration settings Fujitsu Semiconductor Europe GmbH 53 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 3 10 Bt Triggerlnstances This function triggers a BT instance by the software based simultaneous startup register Note Do not use this function unless the selected BT instances are set to either of the following modes e WO mode 5 Software based simultaneous startup mode e UO mode 6 Software based startup and timer start stop mode Even channels only For the BT instance started up by us
41. This function return the status of the Main and Subclock Supervisor Because the CSV STR register is cleared during read the return value is coded in en csv status t which is described below Prototype en csv status t Csv ReadStatus void Return Values Description CsvNoDetection No failure has been detected CsvMainFailure A Main clock failure has been detected CsvSubFailure A Sub clock failure has been detected CsvMainSubFailure Main and Sub clock failures have been detected 5 8 7 CvsCallback This function is called if stc csv config t pfnCallback is defined and the according interrupt is enabled u16FcswbCt1 is the value of the FCSWB CTL register Callback Function VOL Gus Calielback Denel Slo CB Fujitsu Semiconductor Europe GmbH 97 MCU AN 3004 12 E V14 Low Level Library Manual FUJ ITSU Chapter 5 L3 Resource Driver API 5 8 8 Example Code The following code excerpt shows how to set up the CSV include csv h Adjust these window values for own system define CSV_FCS_LOWER 1100 define CSV_FCS_UPPER 1105 uintl6 t ul6FreqErrorVar void CsvCallback uintl6 t ul6FregError ul6FregErrorVar ul6FregError Error handle function ste esy config e SEE EE EE L3 ZERO STRUCT stcCsvConfig tcCsvConfig bMainCsvEnable tcCsvConfig bSubCsvEnable tcCsvConfig bFcsEnable tcCsvConfig bFcsResetEnable tcCs
42. boolean t p OCSA CSTO 0 i FALSE Does not set high level Same for RT1 RT2 RT3 RT4 TRUE i i bRt5High Sets RT5 to high level only if boolean t Level OCSA CST5 0 FALSE Does not set high level Donee S bCmod01 TRUE Sets common mode of RTO and RT1 FALSE Does not set common mode Fujitsu Semiconductor Europe GmbH 189 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API boss DE DUAE TRUE Sets common mode of RT2 and RT3 FALSE Does not set common mode M CUTS BOTAS TRUE Sets common mode of RT4 and RT5 FALSE Does not set common mode bOccpOBuf TRUE Performs buffer transfer of OCCPO ET ME Transfer upon peak value detection Peak FALSE Performs buffer transfer of OCCPO Detection upon zero value detection Same for OCU1 OCU2 OCU3 OCU4 bOccp5Buf TRUE Performs buffer transfer of OCCP5 us Transfer upon peak value detection Peak FALSE Performs buffer transfer of OCCP5 Detection upon zero value detection TRUE operation mode of OCUO in boolean t bMode0 combination with bCmod01 FASLE No combination with bCmod01 Same for OCU1 OCU2 OCU3 OCU4 TRUE operation mode of OCU5 in boolean t bMode5 combination with bCmod45 FASLE No combination with bCmod45 ul60cu0 Uco e Compare Sets the OCUO compare value Value Same for OCU1 OC
43. device type4 device type5 device type6 device type7 define define define define define define define define S ESAE DODENUS o 3 3 5 o 3 3 y OU sos CO CO CO CO CO CO CO CO bm d KEKKKKKKK ck ck KA KAZ A K A A A A ZA ZAZ AXA A AZ A kk A X A A KA ZAZ ck ko A A KA Ck ck ck ko ck ko ko A KA ck ko ck ko Sk A ko ck ck ck ck Mk Sk k ko ko k kk Global Uses Dewice Choice mist FA kk ee ke ke k Ck kCkCk Ck A A A Ck Ck kCkCk Ck KKK ee Ck k Ck Ck Ck k ck Ck ck k ck k KKK KKK define DEVIC E MB9AF10X 0 define EVIC E MB9AF11X 10 define EVIC E MB9AF13X 20 define EVIC E MB9AF31X 30 define EVIC E MB9BF10X 40 define EVIC E MB9BF20X 50 define EVIC E MB9BF30X 60 define E MB9BF31X define E MB9BF41X define E MB9BF51X define E MB9BF61X define E MBOBFD1X Ck ck ck ck kk kk Ck Ck Ck KAZ A K A A AA Ck Ck ZX AXA A X A ZAZ AX A A KA ZA AK AA KA ZA XK AZ A AZ KA kk A ZA A KA KA AK ko ko kc ko KA KKK Global User Package Choice List KKK KK KKK KKK KKK KKK KKK k Ck ck kc KKK KK ck kk Ck ck kc k KKK KK KKK KKK KKK KK KKK ck k ck ck KKK KKK define L3 DEVICE PACKAGI 10 define EVICE PACKAGI 20 define EVICE PACKAGI 30 define EVICE PACKAGI 40 define EVICE PACKAGI 50 define EVICE PACKAGI 60 define EVICE PACKAGI 70
44. elements with prefix Get the Unix time and sets the internal data stc wc intern data u32RawTime Wc GetTime calculates from stc wc intern data u32RawTime the date and time and sets the substructure stc wc config stcCalendar Notes e Because sub clock enable disable is used the sub clock oscillation is checked and is not touched by Wc Init or Wc DeInit if enabled before The WC driver works independently from the CLK driver This driver uses the subclock Connecting a subclock crystal to XA0 and XA1 is mandatory e Because the WC interrupt is shared with other interrupts e g Clock Stabilization Wc Init and Wc DeInit have an argument whether to touch the NVIC registers or not to prevent interference with other driver parts 5 27 1 Configuration Structure The WC has the following configuration structure of the type of stc wc config t Type Field Possible Values Description 7 TRUE boolean t bEnable Eu EU WcPrescalerDiv Prescaler Divisor en wc enPrescaler pe z WCCKS prescaMemke Div EE 2n ERA 125ms 2 WCCKO uint8 t u8SetSecond D 5 Seconds to be set uint8 t u8SetMinute 0 59 Minutes to be set DEES u8SetHour oe Hour to be set maligne E u8SetDay L o sil Day of month to be set uint8 t u8SetMonth NM iil Month to be set uint8 t u8SetYear 0 o 2838 Years since 1900 to be set i CUM i8 setrsdst Time zone and or daylight savings time
45. of PC and ZIN bSwapAin TRUE Swap AIN and BIN inputs bool E Miro Bin FALSE AIN and BIN inputs as there are boolean t bRegister TRUE Compare PC Fujitsu Semiconductor Europe GmbH 217 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Function FALSE Compare RC AE bGate TRUE Count gate function Function FALSE Counter clear function OprcComapre Compares the value of the OPRC RC and RC ml beer de Compare Register OPRCR with that of the Sm OBEC w enComapre Pon Sem ooo E mede pen Compares the value of the QPRC RC and RC DEE Compare Register OPRCR with that of the Revolution Revolution Counter Gj res ila ZIN functionality Disable Disable edge and level detection en qprc MS Soos ZIN active at falling edge zinedge t pU E pun e ZIN active at rising edge BothEdges ZIN active at falling or rising edge LowLevel ZIN active at low level detection Bo ZIN active at high level detection OprcBin BIN functionality en qprc S pu Disable edge and level detection binedge t zd pu E BIN active at falling edge ee Eee BIN active at rising edge BothEdges BIN active at falling or rising edge OprcAin AIN functionality an Core e Tm s Disable edge and level detection binedge t E rs FallingEdge AIN active at falling edge
46. tcRtcConfig pfnTimerCallback amp Rtc TimerCallback tcTimerConfig u32TimerValue 1234 tcTimerConfig bTimerIntervalEnable FALSE u8TimerRun 1 Rtc TimerSet pstcRtc amp stcTimerConfig Rte TimerStart pstcRte while 1 u8TimerRun wait for timer finished via callback Fujitsu Semiconductor Europe GmbH 247 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 26 USB USB Host and USB Device For the USB functionality please refer to the following application notes e mcu an 300122 FM3 devices and Virtual COM Port usage e mcu an 300124 Manual for the Fujitsu USB Assistant USB Wizard e mcu an 300126 Description of the Fujitsu USB Host Stack e mcu an 300131 Description of the Fujitsu NET Library FujitsuUsbLib e mcu an 300132 Description of the Fujitsu USB Device Library e mcu an 300411 USB Host Mass Storage Boot Loader application MCU AN 300412 E V14 248 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 27 WC Watch Counter Type Definition ste won Configuration Type stc wc config t Address Operator WCn Wc Init has to be called after configuration date time prescaler settings etc was done This driver module uses the time h standard library Wc SetTime calculates from the date and time given in the configuration from the
47. void CanTxCallback uint8 t u8MsgBuf 5 4 9 CanRxCallback Callback Function void CanRxCallback uint8 t u8MsgBuf SECCO S oM MED Sie e ES CD 5 4 10 CanStatusCallback This function is called if stc can config t pfnStatusCallback is defined Callback Function void CanStatusCallback en can status t enCanStatus The enumerators of en can status t are Enumerator Description CanNoError No error pending More than 5 equal bits in a sequence have occurred in a part of a received message Cano EWE E IBS EHE CanFormError A fixed format part of a received frame has the wrong format The message this CAN Core transmitted was not acknowledged by another node GankAekkeron EN While trying to send a recessive bit 1 a dominant level 0 was sampled oso While trying to send a dominant bit 0 a recessive level 1 was sampled CanCRCError The CRC checksum was incorrect MCU AN 300412 E V14 68 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 4 11 CanErrorCallback This function is called if stc can config t pfnErrorCallbackis defined Callback Function void CanErrorInterruptCallback en can error t enCanError The enumerators of en can error t are Enumerator Description CanBusOff The CAN module is
48. 0 S Data no LIN meaning just test byte au8TxBuffer 1 T Checksum no LIN meaning just test byte and send data u32CountRxCb 0 Mfs Write pstcMfs char amp au8TxBuffer 2 FALSE Wait for all data read while u32CountRxCb 2 Fujitsu Semiconductor Europe GmbH 185 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 21 MFT Multi Function Timer Type Definition See mitn te Configuration Type FRT and OCU stc mft frt ocu config t Configuration Type WFG S a get Configuration Type PPG s t ppg config t Configuration Type ICU SiC mft _icu config t S S S ce m tc m Configuration Type ADCMP Ee d Configuration Type NZCL Configuration Type IGBT Address Operator MFTn t adcmp config t E mul COmELG e E tele Comics ic ce m ifs if it iti iti iti tc m A Multi Function Timer instance consists of the following components 3 FRT 3 Free Run Timer OCU 6 Output Compare Unit Channels 3 WFG 3 Waveform Generator Units 3 PPG 3 dedicated PPG Channels 4 ICU 4 Input Capture Channels 3 ACMP 3 ADC Compare Trigger Units 1 NZCL 1 Noise Cancel Emergency stop Unit 1 IGBT 1 IGBT module for Tpye7 devices only The components marked by above are needed for the minimum configuration stc mft frt ocu config t to initialize an MFT instance Thus the FR
49. 20 MFS Multi Function Serial Interface Type Definition ste mien ic Configuration Type stc mfs config t Address Operator MFSn Mfs Init must be used for activation and setup of an MFS channel Al MFS connection related parameters can be set with parameter pstcConfig of type stc mfs config t The following restrictions have to be considered There must be a start bit in MFS asynchronous mode The clock source must be MfsUseExternalSerialClockSourceAsItIs in MFS synchronous slave mode e Continuous clock output must only be active in MFS synchronous master mode On initialization the API has to provide a memory location for receive and transmit buffer handling also for DMA usage The memory location will be set on initialization with stc mfs config t pcTxBuffer stc mfs config t ul6TxBufferSize pcRxBuffer and stc mfs config t ul6RxBufferSize EE E stc mfs config FF The MFS initialization will create a receive and transmit ring buffer on this memory location and handle all ring buffer related parameters stc mfs buffer t So each MFS instance will consist of a 2 step buffer handling by combination of the ring buffer with the hardware internal fifo buffer The length of the receive and transmit hardware FIFO is MFS FIFO MAX VAL usually 16 The receive and transmit interrupt level of each hardware FIFO is set internall
50. Containing all resource drivers and headers emac Containing all Ethernet parts Usb config Containing UsbConfig c h Usb middleware Containing all middleware USB parts Adjust the preprocessor search paths to Project start directory gt common Project start directory gt example Source Project start directory gt example source emac Project start directory gt example source I3 Project start directory gt example source usb middleware Project start directory2 example source usb config The workspace should get the following groups as shown in the following graphic which show IAR Workbench and KEIL s u Vision screenshots Fujitsu Semiconductor Europe GmbH 21 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 3 Using L3 in own Application Projects Attention Files gt We 13 Debug common La E system mb9bf50x c crtrim c E csv c C dac c C dma c C dsm c Date E exint c E extif c E flash c E interrupts c E l3 c E lvd c E mfs c C mft c qprc c C ramcode c E reset c E rtc c usb c C usbdevice c usbethernetclock c C usbhost c C1 we c wdg c AU source files C main c Ach startup mb9bf50x s El usb config D UsbConfig c Ha usb middleware D UsbClassSupervisor c E UsbHostHidCom c Ha E UsbHostHidKeyboard c E UsbHostHidMouse c Readme bd E Output 7 UsbDeviceClass
51. DT CHANNEL COUNT 5 12 9 Dt DirectWriteLoadChannel This function writes directly without configuration pstcConfig to the load register of the given DT channel by u8Channel Prototype SNS CC tee SCEE adehannel EE temm DSi c blalimeS2 u32DtLoad Dimes 16 u8Channel Parameter Name Description in psteDt Dual Timer instance pointer in u32DtLoad DT Load register value in u8Channel Oor1 Return Values Description Ok Channel disabled ErrorlInvalidParameter pstcDt NULL u8Channel DT CHANNEL COUNT 5 12 10 Dt DirectWriteBgLoadChannel This function writes to the background load register of the given DT channel via configuration pstcConfig by u8Channel Fujitsu Semiconductor Europe GmbH 115 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype en result t Dt DirectWriteBgLoadChannel volatile stc dtn t pstcDt unne Se u32DtLoad EE u8Channel Parameter Name Description in pstcDt Dual Timer instance pointer in u32DtLoad DT Background Load register value in u8Channel Oor1 Return Values Description Ok Channel disabled ErrorInvalidParameter e pstcDt NULL u8Channel gt DT CHANNEL COUNT 5 12 11 Dt ReadValueChannel This function returns the recent value of the DT count of Channel u8Channel In 16
52. Dual Timer instance pointer in bTouchNVIC TRUE NVIC is initialized FALSE NVIC registers are not touched Return Values Description Ok Internal data has been setup ErrorInvalidParameter PSD EN VIE Note This function does not initialize the DT channels itself Dt_SetChannelConfig has to be called for each channel you wish to use after Dt_Init 5 12 3 Dt_Delnit This function de initializes the DT module Differently to the Dt init function Dt DeInit also accesses the DT hardware register They are set to 0 default reset values The configuration is not changed but the callback pointers are reset to NULL Prototype SMS SUN t De Date voleiculo Stre cen t7 PErCDE boolean t bTouchNVIC Parameter Name Description in pstcDt Dual Timer instance pointer in bTouchNVIC TRUE NVIC is reset FALSE NVIC registers are not touched Return Values Description Ok Registers and internal data have been cleared ErrorInvalidParameter psteDt NULL MCU AN 300412 E V14 112 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 12 4 Dt SetChannelConfig This function initializes the given DT channel The parameters are checked for plausibility and the given callback is stored internally The timer enable pstcConfig gt bEnable can be set to start the timer via this function Alternatively the e
53. Enable DTIF IRQ from DTTIX pin boolean t EST U JOE FALSE Disables DTIF int t Enable SE isables interrup MftNzclNo Direct DTTIX pin connection w o NoisCancel noise canceling MftNzclNoise Noise canceling with 4 PCLK cycles Cancel4Pclk en mft nzcl enNoice MftNzclNoise Noise canceling with 8 PCLK cycles cala Te CancelTime Cancel8Pclk MftNzclNoise Noise canceling with 16 PCLK cycles Cancell6Pclk MftNzclNoise Noise canceling with 32 PCLK cycles Cancel32Pclk Cu ES PN ede Callback function pointer of DTIF EB Callback interrupt 5 21 1 7 IGBT Configuration The IGBT has the configuration of the type of stc mft igbt config t Note that this configuration is only available for Device Type 7 Type Field Possible Values Description e ce bStop DEN Stop prohibition mode in output active ProhibMode FALSE Normal operation Senami pol MftPpgIgbt i m vu NoFilter No noise filter operation MONS EMA E CTA Mft PpgIgbt Fujitsu Semiconductor Europe GmbH 197 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API o NSE Noise filter with 4 PCLK cycles MftPpgIgbt epee EEC Noise filter with 8 PCLK cycles MftPpgIgbt 16PclkFilter Noise filter with 16 PCLK cycles MftPpgIgbt 32PclkFilter Noise filter with 32 PCLK cycles boolean t bInverted TRUE OutputO level inverted
54. Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Dma Set Channel amp stcCrcDmaConfig Trigger DMA while 0 u8DmaFinished Wait for DMA finished usZerneResulit ire ReadResuise stereren e V eRGODJ Do something with result value Fujitsu Semiconductor Europe GmbH 91 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 7 CRTRIM CR Trimming Type Definition Configuration Type Address Operator The trimming function Crtrim SetTrimmingFromFlash copies the Flash HS CR trimming data to the trimming register of the HS CR Clock If all bits of this data are equal to 1 erased CR Trimming Sector result t ErrorInvalidParameter returned and the trimming register remains unchanged Crtrim SetTrimming sets the function s argument to the HS CR trimming register Note e IfL3 PERIPHERAL ENABLE CRTRIM FLASH is set to L3 ON in 3_user h also the function Crtrim UpdateFlash is compiled L3 NO FLASH RAMCODE must be set to L3 OFF and L3 PERIPHERAL ENABLE FLASH to L3 ON in this case e The CR Trimming process like Crtrim SetTrimmingFromFlash is also done in System init in the system mb9 ab xyz c file It can be switched off by defining CR TRIM SETUP to 0 in system mb9f ab xyz h 5 7 1 Crtrim SetTrimmingFromFlash This function copies the data of the Flash CR trimming contents
55. Flash memory area 5 16 6 Flash WriteEccBlock This function writes a data block to the ECC Flash memory The data and count is 16 Bit width The return code ErrorInvalidParameter is returned when an input parameter is incorrect or if one data value can not be written because of an not empty ECC 32 bit cell ECC does not support Flash cell update without ECC error The address u32FlashAddress must be 16 Bit aligned even address Note this function is only available if the device supports ECC Flash otherwise this function is excluded by the preprocessor MCU AN 300412 E V14 138 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype en result t Flash WriteEccBlock uint32 t u32FlashAddress pabenedl S EE uint32 t u32DataLength Parameter Name Description in u32FlashAddress Flash address in pul6Data Pointer to 16 Bit data block in u32DataLength 16 Bit data block length Return Values Description Ok Flash programming was successful ErrorTimeout Automatic programming algorithm timed out ErrorAddressAlignment u32FlashAddress not an even address ErrorOperationInProgress Flash not ready to be programmed ErrorlInvalidParameter e pu8Data NULL e u32DataLength 0 Flash data cannot be programmed because one or more bits cannot be programmed from
56. Interrupt voltage in the vivinity of 1 80 Volts C LvdirqVoltage185 Interrupt voltage in the vivinity of 1 85 Volts C LvdIrqVoltagel90 Interrupt voltage in the vivinity of 1 90 Volts C LvdirqVoltagel195 Interrupt voltage in the vivinity of 1 95 Volts C DvdIrgVoltage200 Interrupt voltage in the vivinity of 2 00 Volts C DvdIrgVoltage205 Interrupt voltage in the vivinity of 2 05 Volts C LvdIrgVoltage250 Interrupt voltage in the vivinity of 2 50 Volts C LvdIrqVoltage260 Interrupt voltage in the vivinity of 2 60 Volts C LvdirqVoltage270 Interrupt voltage in the vivinity of 2 70 Volts C DvdIrgVoltage280 Interrupt voltage in the vivinity of 2 80 Volts C DvdIrgVoltage290 Interrupt voltage in the vivinity of 2 90 Volts C LvdIrgVoltage300 Interrupt voltage in the vivinity of 3 00 Volts C DvdIrgVoltage310 Interrupt voltage in the vivinity of 3 10 Volts C DvdIrgVoltage320 Interrupt voltage in the vivinity of 3 20 Volts C LvdIrgVoltage20 Interrupt voltage in the vivinity of 2 0 Volts B LvdIrqVoltage21 Interrupt voltage in the vivinity of 2 1 Volts B MCU AN 300412 E V14 150 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU LvdIrgVoltage22 Interrupt voltage in the vivinity of 2 2 Volts B DvdIrgVoltage23 Int
57. Just a random tConfig0 bTriggerIrgEnable FALSE tConfig0 bUnderflowIrqEnable TRUE tConfig0 bDutyIrgEnable TRUE tConfig0 pfnCallbackl amp BtOCallbackUf underflow irq callback r TE Erde SU S S S S S S S S S S S S S tConfigl enMode BtPpg tConfigl enPrescaler BtIntClkDiv4 tConfigl bRestart TRUE tConfigl bOutputLow FALSE tConfigl bOutputInvert FALSE tConfigl bTimer32 FALSE PPG has no 32 bit mode tConfigl bOneShot FALSE tConfigl enExtTriggerMode BtTriggerRisingEdge tConfigl ul6LowWidth 0x0200 Just a random tConfigl ul6HighWidth 0x0100 Just a random tConfigl bTriggerIrgEnable FALSE tConfigl bUnderflowIrqEnable TRUE tConfigl bDutyIrgEnable TRUE tConfigl pfnCallbackl amp BtlCallbackUf underflow irq callback mW Q o WU W uo uu u W OY W tIoselConfig enBtInstance BtSel01 Combine BTO and BT1 tIoselConfig enMode BtMode5 sw based simultaneous startup t ResetIoSel Ok Bt Tnit ste btn C sBTO amp stocBECOnfug0 OEC BE mit Steen CBS StcBtEConttei Bt Enable stc btn t amp BTO Bt Enable stc bro t amp BT1 Set I O mode 5 sw based simultaneous startup for BTO and BT1 Bt InitIoSel amp stcBtloselConfig Fujitsu Semiconductor Europe GmbH 59 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapt
58. LvdResVoltagel70 Reset voltage in the vivinity of 1 70 Volts C LvdResVoltagel75 Reset voltage in the vivinity of 1 75 Volts C LvdResVoltagel80 Reset voltage in the vivinity of 1 80 Volts C LvdResVoltagel85 Reset voltage in the vivinity of 1 85 Volts C LvdResVoltagel90 Reset voltage in the vivinity of 1 90 Volts C LvdResVoltagel95 Reset voltage in the vivinity of 1 95 Volts C LvdResVoltage200 Reset voltage in the vivinity of 2 00 Volts C LvdResVoltage205 Reset voltage in the vivinity of 2 05 Volts C LvdResVoltage250 Reset voltage in the vivinity of 2 50 Volts C LvdResVoltage260 Reset voltage in the vivinity of 2 60 Volts C LvdResVoltage270 Reset voltage in the vivinity of 2 70 Volts C LvdResVoltage280 Reset voltage in the vivinity of 2 80 Volts C LvdResVoltage290 Reset voltage in the vivinity of 2 90 Volts C LvdResVoltage300 Reset voltage in the vivinity of 3 00 Volts C LvdResVoltage310 Reset voltage in the vivinity of 3 10 Volts C LvdResVoltage320 Reset voltage in the vivinity of 3 20 Volts C LvdResVoltagel53 Reset voltage in the vivinity of 1 53 Volts B LvdResVoltagel93 Reset voltage in the vivinity of 1 93 Volts B Fujitsu Semiconductor Europe GmbH 151 MCU AN 300412 E V14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 19 2 Lvd Initlrq Initialization of the LVD Interrupt at user defined voltage threshold If LVD reset voltage i
59. Maskable HardFault IROn 3 Hard rault ir CANO IROn SL OCN ch 0 CANT IROn Se cat ch 1 IROn Type Figure 6 3 Interrupt NVIC Enumerators of Device s Header File mb9 ab xyz h 6 4 Interrupt Types The L3 only supports interrupts of Type A Additionally the TROCMODER functionality is not supported Fujitsu Semiconductor Europe GmbH 259 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 6 Restrictions 6 5 MFSand DMA Because of the extensive usage of internal buffers user buffers interrupts and if existing FIFOs of the Multi Function Serial Interfaces DMA capability was not implemented in the DEL Nevertheless the user can initialize an MFS instance and use DMA transfer together with the MFS instance but cannot reuse any of the provided API functions An own buffer handling and DMA trigger has to be developed pstcMfs gt u8SCR TXE and pstcMfs gt u8SCR RXE has to be implemented for start stop control of the DMA 6 6 UC Slave Mode The Slave mode of DC is not implemented yet Version 1 7 Future versions of the LLL will cover this functionality 6 7 Alternative Interrupt Vector Tables The FM3 family provides three different types of interrupt vector tables depending on the device The interrupt vector tables are numbered by the letters A B and C The recent version of the LLL 1 7 only provides interrupt vector type A 6 8 LCD LCD is not provided in the recent LLL
60. Multifunction Timer has a very wide configuration complexity only some basic examples can be given here 5 21 28 1 Basic FRT Operation with OCU Output This code shows how to initialize the MFT for FRT OCU Output Fujitsu Semiconductor Europe GmbH 209 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include me ola function SCM EO CU ee DEA St cem fte mete Gs pstcMft L3 ZERO STRUCT stcMftFrtOcuConfig FRT settings ES ES tcM lt EE CC Ee EE CC Ee CC ES CC ES CC ES CC EE CC EE ES CC CC CC CC CC CC EPrEOcuContag tFrtOcuConfig tFrtOcuConfig Elle DIE eet LEO CUCOnfuc tFrtOcuConfig tFrtOcuConfig poo CU Oni tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig lt lt lt lt lt lt lt lt lt lt Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Eh Fh Fh Fh Fh Fh Fh Fh Fh Fh S S S S S S S S S S S S S S S S S S S S S S S S S S S E o ha th hn Eh tah ahi sb e Es EN EEE Eod sb Es e Eth es he sho Ese she hon ste ehe Cm U settings tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig LErtOCuGOomfuc ct OcuConfuc tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig Ebo CU Onfuc tFrtOcuConfig tFrtOcuConfig EBEtOcuContic tFrtOcuConfig Blees NG tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuC
61. NAND ADDRESS NAND CMD RESET Extif Wait 10000 wait for Trst depends on HCLK static unsigned char Nand ReadStatus void uint32_t u32Timeout 0 Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD STATUS while Extif Nand ReadData EXTIF NAND ADDRESS amp 0x40 u32Timeout if 0x00080000 u32Timeout return NAND FLASH ERROR Extif Nand ReadData EXTIF NAND ADDRESS amp 0x01 return NAND FLASH ERROR return NAND FLASH OK MCU AN 300412 E V14 130 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU static void Nand ReadID uint8 t u8MarkerCode uint8 t u8Id Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD READID Extif Nand SetAddress EXTIF NAND ADDRESS 0x00 Extif Nand ClearAle EXTIF NAND ADDRESS Extif Wait 10 u8MarkerCode Extif Nand ReadData EXTIF NAND ADDRE u8Id Extif Nand ReadData EXTIF NAND ADDRE static uint32 t Nand EraseBlock uint32 t u32Block uint32 t u32BlockPage u32Block 5 Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD ERASE1 erase command Extif Nand SetAddress EXTIF NAND ADDRESS 0 Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage amp OxFF Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage gt gt 8 amp OxFF Possible further address cycles here
62. S S S S S S S S S S S S S S S S S S tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOcuConfig tOCcuComfug pfnOcu5Callback pfnFrtOPeakCallback pfnFrtlPeakCallback pfnFrt2PeakCallback p nFrt0ZeroCallback pfnFrtlZeroCallback pfnFrt2ZeroCallback pfnOcu0Callback pfnOculCallback pfnOcu2Callback pfnOcu3Callback pfnOcu4Callback G settings tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig enWfgClock01 enWfgClock23 enWfgClock45 enWfgMode01 enWfgMode23 enWfgMode45 enWfgGate01 enWfgGate23 enWfgGate45 enWfgPpgSel01 enWfgPpgSel23 enWfgPpgSel45 enWfgPpgEnable01 enWfgPpgEnable23 enWfgPpgEnable45 Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh WN H e en za dum E E Dum tWfgPclkl tWfgPclkl tWfgPclkl tWfgPpgPpg tWfgPpgPpg tWfgPpgDeadTimerMode tWfgPpgDeadTimerMode tWfgPpgDeadTimerMode tWfgRtOFlagO tWfgRtOFlagO tWfgRtOFlagO tWfgGatePpg0 tWfgGatePpg2 tWfgGatePpg4 tWfgPpgPpg SE SE FALSE 0x40 0x807 USCH tr D tWfgConfig bNonOverlapHighPolarity0 tWfgConfig bNonOverlapHighPolarityl tWfgConfig bNonOverlapHighPolarity2 tWfgConfig ul6WfgOlTimerValue tWfgConfig ul6W
63. TRUE Print message Mfs WriteString pstcMfs n rSent String O Print via Mfs Write scanned string 9 characters u32CountTxCb 0 Mfs Write pstcMfs char amp au8ReadBuffer 9 FALSE while 0 u32CountTxCb ff Wake for Finish Mfs DeInit pstcMfs 5 20 35 2 Asynchronous Communication via Mfs_Asynclnit This example shows how to use the MFS initialization via Mfs AsyncInit The same code from above 5 20 35 1 can be used for communication finclude mfs h define BUFFERSIZE 256 No ring buffer definitions needed for Mfs AsyncInit uint32 t u32CountTxCb 0 uint32 t u32CountRxCb 0 void MfsOTxCallback void u32CountTxCbtt void MfsORxCallback void u32CountRxCb function No user MFS configuration needed for Mfs AsyncInit stc mfsn t pstcMfs NULL MFS instance char au8ReadBuffer 256 MCU AN 300412 E V14 176 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU const uint8 t cszString Hello world uintl6 t ul6ReadCount xf Ok gt MfS IAsnetnit stemtEsn tt MESO 115200 MfsParityNone MfsOneStartStop amp MfsOTxCallback amp MfsORxCallback usual instance pointer bits per second Do parity FS bark Bit 1 stop DIt TX Callpack Potter Rx Callback pointer Setup pointer to USART instance psieMBSE ENStcsemfsnagst e
64. The next and last interrupt then stores the 4 FIFO conversions for the 2 buffers the interrupt is disabled and the callback function is called for end notification to the application The figure above shows the state where the 1 interrupt have been occurred and the buffers have been updated with the 8 bytes each in the interrupt service routine of the driver The callback function call which will be called later is shown in dashed lines 5 2 2 DMA Scan Conversion If DMA is used there is no method to fill channel dedicated buffers Therefore the user has to know that the full 32 Bit FIFO data is stored in a single buffer After the DMA event and thus the filled buffer the software has to read out the channel data to determine which channel data was stored If a single channel conversion is desired the channel bits of the FIFO are obsolete In this case a single buffer can be filled with the conversion data only by using the upper 16 Bit of the SCFD register as the DMA data source 5 2 3 Configuration Structure An ADC instance uses the following configuration structure of the type of stc adc config t MCU AN 300412 E V14 38 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Type Field Possible Values Description Steg mel 32 Bit ADC channel bitfield LSB u32Cannel channel
65. UpdateAndTransmitMsgBuffer can be used with the same message buffer index With the parameter stc can msg id t pstcMsgId of type stc can msg id t the API can set the identifier 11 bit or 29 bit length of the CAN transmit message It is possible to set a callback function to get notified when a transmission is successfully finished Can SetTransmitMsgBuffer must be called before calling Can UpdateAndTransmitMsgBuffer Update or setting of new values of function MCU AN 300412 E V14 64 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Can SetTransmitMsgBuffer or Can UpdateAndTransmitMsgBuffer is not possible if a transmission is pending or ongoing except remote transmission mode is used Prototype en result ct Can SetiransmtMsqBurtter volatile ste cann ts pstcCan UTE SEE u8MsgBuf emeng SEI Cem meg iC t7 PETENGE Cam ex meg CUME ore tE pfnCallback Parameter Name Description in pstcCan CAN instance pointer de in u8MsgBu Message buffer index 0 CAN MESSAGE BUFFER COUNT 1 in pstcMsgId CAN message identifier in pfnCallback Callback function to be called after successful transmission can be NULL Return Values Ok ErrorInvalidParameter Description Message
66. Value Description Ok Time successfully started ErrorInvalidParameter pstcRtc NULL 5 25 14 Rtc TimerStop This function stops the Timer of the RTC Timer The RTC has to be initialized before to use this function properly Also use the Timer Interrupt enable by Rtc Init Prototype em result t RCE Timersrtace volarile sue TECH E7 Dude Parameter Name Description in pstcRtc RTC instance pointer Return Value Description Ok Time successfully stopped ErrorInvalidParameter pstcRtc NULL 5 25 15 Rtc TimerStatusRead Read Timer Status of RTC This function provides the status of the TMRUN bit of the WTCR2 register It returns the type en rtc timer t as described below Fujitsu Semiconductor Europe GmbH 241 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype Sa tO Cimer Scarus E Ree WilwerSices wolacile Sue ecm SES C Parameter Name Description in pstcRtc RTC instance pointer Return Value Description RtcTimerNoOperation Timer counter is not operating RtcTinerInOperation Timer counter is operating RtcInvalidInstance pstcRtc NULL 5 25 16 Rtc_GetRawTime This function calculates the raw time UNIX time It uses mkt ime of the time h library Prototype CMOS ECG SER Tame SCC M
67. WFG01 count clock cycle PCLK 2 MftWfgPclk4 WFG01 count clock cycle PCLK 4 en mft wfg clock t enWfgClock01 MftWfgPclk8 WFG01 count clock cycle PCLK 8 MftWfgPclk16 WFG01 count clock cycle PCLK 16 MftWfgPclk32 WFG01 count clock cycle PCLK 32 MftWfgPclk64 WFG01 count clock cycle PCLK 64 en mft wfg clock t enWfgClock23 see above see above for WFG23 en mft wfg clock t enWfgClock45 see above see above for WFG45 MftWfgThrough WFG01 operation in through mode Mode MftWfgRtPpg WFG01 operation in RT PPG mode Mode TN MftWfgTimer WFG01 operation in Timer PPG PpgMode mode MftWfgRtDead WFG01 operation in RT Dead Timer TimerMode mode MftWfgPpgDead WFG01 operation in PPG Dead TimerMode Timer mode en mft wfg mode t enWfgMode23 see above see above for WFG23 en mft wfg mode t enWfgMode23 see above see above for WFG45 ftWfgLowLevel Outputs low level signal ftWfgRtOFlagO0 Outputs RT 0 Timer active FlagO B o ftWfgRtlFlagl Outputs RT 0 Timer active Flag1 ftwfgRt10Flagl0 Ored signal from FlagO and Flag ftWfgLowLevel Outputs low level signal ftWfgRtOFlagO Outputs RT 2 Timer active FlagO um c MEI a ftWfgRtlFlagl Outputs RT 2 Timer active Flag1 ftwfgRt10Flagl0 Ored signal from FlagO and Flag1 ftWfgLowLevel Outputs low level signal ftWfgRtOFlagO Outputs RT 4 Timer active FlagO M a E ftWfgRtlFlagl Outputs RT 4 Timer active Flag1 ftWfgRtl0Flagl10 Ored signal from FlagO and Flag1 Home MftWfgGatePpgO WF
68. Z A ZAZ kk AXA A ck ck ck ko A KA A KA ZAZ A X A A KA ZA AZ ko A A AA ZA ck ko A ko Sk A ko ck ck ko k k ko ko ko ko ko brief Hook function which is called in polling loops kk This functionality has to be mirrored in ramcode c if RAM code is used KKK KK KK KK KK KKK ck Ck k Ck kk kk KKK KK kk ck kc KKK KKK KKK kk kk kk kk kk kk kk ck k ck k ck k ck ck KKK KKK void L3 WAIT LOOP HOOK void Place code for triggering Watchdog counters here if needed Note that for RAM code functions such as Flash programming routines the user code also has to be set in ramcode c s function see chapter 5 23 static void L3 RAMCODE WAIT LOOP HOOK void MCU AN 300412 E V14 24 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 4 L3 Main Files 4 3 File I3 h First the 3 h file defines the device type the FM3 device names and package code This file should not be changed by the user ck ck ck ck kk kk Ck Ck Ck KAZ A KA A AA KA ZK AX A A X A ZAZ AX A A KA ZA AK AA KA Ck Ck kk kk AZ KA ZK A ZA A KA KA Mk Mk ko ko kc ko ko ck k Sm odetimetonsmneededitor Ms user nhl are stated her Fe ck Ckck kc k Ck k kc k Ck k Ck ee ee ee KKK KKK KKK ck Ck ck k ck k ee ee ae a ae define L3 ON 1 Switches a feature on define L3 OFF 0 Switches a feature off TS PRE EIE ER AIRES ER V es VES device type0 device typel device type2 device type3
69. a zi FALSE CRC result not as XOR value TRUE Result bit order LSB first P PS on Vs FALSE Result bit order MSB first Ce TRUE Result byte order LSB first boolean t bResultLittleEndian FALSE Result byte order MSB first e TRUE Data bit order LSB first De nene yug qu ne FALSE Data bit order MSB first TOME TRUE Data byte order LSB first boolean t bDataLittleEndian FALSE Data byte order MSB first uint32 t u32CrcInitValue 0 OxFFFFFFFF Initial CRC value 5 6 2 Crc Init This function initializes the CRC macro It has the following format Prototype sm result t Cue mile Ste Cren ic See ewer SEG Cree Comrie ue PECCCONTLC Parameter Name Description dal pstetze CRC instance pointer in pstcConfig CRC module configuration see above Return Values Description Ok Initialization of CRC module successfully done ErrorInvalidParameter e psteDt NULL e Parameter out of range MCU AN 300412 E V14 86 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 6 3 Crc Delnit This function de initializes the CRC macro It has the following format Prototype Sm result Cee OHM Ses ceca E sree C c Parameter Name Description nosem CRC instance pointer Return Values Description Ok De Initialization of CRC module successfully done nvalidParameter Teo Ne
70. be NULL Ne Pointer to ADCMP configuration structure This in pstcAdcmpConfig pointer can be NULL oe i Pointer to PPG configuration structure This pointer in pstcPpgConfig can be NULL Return Values Description Ok MFT initialization successfully done ErrorInvalidParameter pstcMft NULL oscar e UNE pstcMfsInternData NULL Instance could not be resolved e One or more configuration data wrong e Wrong enumerator used or enumerator not supported 5 21 3 Mft Dein This function de initializes an MFT instance and disables all according interrupts Fujitsu Semiconductor Europe GmbH 199 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype Sm wesc te Mre Dette Sto meca ET psteMft SEE wre rre OCU Comte OSE SHO Erste SEE NEW GC Eer e pstcWfgConfig See mee mel Fom tr psteNzemeont ie SES mite SL ener 169 pstelcuContig SECS met Elementer ie pstcAdcmpConfig SEC mita 9 e ler ic pstcPpgConfig Parameter Name Description in pstcMft Pointer to MFT instance e Pointer to FRT and OCU configuration structure Ahh MOSES cuco This pointer can be NULL e S Pointer to WFG configuration structure This pointer in pstcWfgConfig a can be NULL ee Pointer to NZCL configuration structure This pointer Lal eneen LE E can be NULL t Pointer to ICU configuration structure This point
71. buffer vincle won Length of reception buffer Fujitsu Semiconductor Europe GmbH 157 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Buffer Size pf nLin in Je op e Es d Break Pointer to Lin Break callback function Callback ES ee Clo jooo A iua puc E GST TS CE Pointer to reception callback function ware sess ele PEN Pointer to transmission callback UMCH CNC Callback function 5 20 3 3 IC Noise Filter Configuration Because each MFS has an own noise filter if supported by device type these noise filters have an own configuration structure of the type of stc mfs dnf t Type Field Possible Values Description DnfNoFilter No noise filter APB1 clock 40 MHz DnflStepFilter 1 step noise filter APB1 clock 60 s MHz Dnf2StepFilter 2 step noise filter APB1 clock 80 MHz Dnf3StepFilter 3 step noise filter APB1 clock 100 lt MHz en mre dnf t enDnf0 5 20 4 Mfs Init This Function initialises the MFS according the Options setup in the passed configuration strucutre Several checks are done before that and an error is returned if invalid modes are requested These rules are checked e A start bit must be used in asynchronous mode e External clock source as it is must be used in synchronous slave mode Pointer to receive and transmit buffer mus
72. callback boolean t bDutyI rq TRUE PWM Enable duty match IRQ and callb MCU AN 3004 12 E V14 50 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Enable FALSE PWM No duty match IRQ and callb IRQ1 callback PWM Timer start trigger pfn detection cune per ELO E e PPG Timer start trigger detection RLT Timer start trigger detection PWC Completion of measurement detection IRQO callback Sen e PWM Underflow detection neppe AE e PPG Underflow detection RLT Underflow detection e PWC Overflow detection pfn IRQO callback Sune SpE rae Callback2 E PWM Match in duty detection 5 3 1 2 Base Timer I O Selectors The Base Timer I O Selectors have the following configuration structure of the type bt_iosel config t Type Field GE Description BtSel01 Selector for BTO and BT1 en bt iosel onptInstance BtSel23 Selector for BT2 and BT3 instance t BtSel45 Selector for BT4 and BT5 BtSel67 Selector for BT6 and BT7 BtMode0 Standard 16 bit timer mode BtModel Timer full mode BtMode2 Shared external trigger mode T BtMode3 Shared channel signal trigger mode sve enMode BtMode4 Timer start stop mode BtMode5 SW based simultaneous startup mode BtMode6 SW based startup and timer start stop mode BtMode7 Timer start mode BtMode8 Shared ch signal timer and timer start stop
73. callback function 7 KK KK KK kk ki kk kk KA RR k KA RR RR RR RR k kc k kc k KA kc kckck kc kckckckckokckok kok ck ok ko ke ke ke kx void EICallback void Do something after wake up function seccion tao E stcClkConfig Stclexint config t stchiConfig ERO STRUCT stcClkConfig ERO STRUCT stcEIConfig 3 21 3 2 Setup External Interrupt Ch40 for system wake up stcEIConfig abEnable 0 TRUE stcEIConfig aenLevel 0 ExIntFallingEdge stcEIConfig apfnExintCallback 0 amp EICallback Exint Init amp stcEIConfig Transition to Sleep Mode stcClkConfig enMode ClkSleep Clk SetMode amp stcClkConfig Wakeup with external interrupt 0 here Transition to Timer Mode stcClkConfig enMode ClkTimer Clk SetMode amp stcClkConfig Wakeup with external interrupt 0 here jf Transition to Stop Mode stcClkConfig enMode ClkStop Clk SetMode amp stcClkConfig Wakeup with external interrupt 0 here 5 5 24 5 Using Clk_GetParameters for configuration set Sometime it is useful only to change some clock configuration parameters but the exact clock configuration state may be unknown during application run time In this case Clk GetParameters can be used The following code shows how to do this MCU AN 3004 12 E V14 84 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resour
74. channel number uintiG t Recent ICU channel counter value 5 21 10 Mft_PpgSwTrigger Triggers PPG channels of an MFT instance by Software Prototype en result t Mft PpgSwTrigger SEG mireia i EE boolean t bPpg0 boolean t bPpg2 boolean t bPpg4 Parameter Name Description in pstcMft Pointer to MFT instance TRUE Triggers PPGO bPpgo e E B3 FALSE Preserve PPGO operation state E TRUE Triggers PPG2 Ppg2 e E FALSE Preserve PPG2 operation state we TRUE Triggers PPG4 Ppg4 SE FALSE Preserve PPG4 operation state Return Values Description Ok Dedicated PPGs triggered ErrorlInvalidParameter pstcMft NULL pstcMfsInternData NULL Instance could not be resolved e Intance number of internal data out of range corrupted Fujitsu Semiconductor Europe GmbH 203 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 21 11 Mft PpgSwStop Stops PPG channels of an MFT instance by Software Prototype sm reste e VED SMOE DA Sue wren C PECCNEG boolean t bPpg0 boolean t bPpg2 boolean t bPpg4 Parameter Name Description in pstcMft Pointer to MFT instance UT TRUE Stop PPGO a FALSE Preserve PPGO operation state m TRUE Stop PPG2 p3 FALSE Preserve PPG2 operation state cca TRUE
75. ck ck ck kk kk Ck Ck Ck KA kk A AA KA ZX AXA A XZ A kk AX A A KA ZA AK AA KA ZA XK AZ A AZ KA kk AKA A KA KA AKA kc ko ko KA A Global device definition See 13 h for select list wok note This definition is used for GPIO settings interrup User Device A enumeration handling Name Ck ck ck ck kk kk kk ck kk kk kk Sk kk kk ko ko kc ko KK KKK Ck ck ckck kck ck ckockck ckck KA kk ck k ck ck kk define L3 MCU L3 DE F E MB9BF50X 4 4 2 Package Definition Together with the device name the L3 is able to determine the device type Therefore the package has also to be defined ck ck ck ck kk kk Ck Ck ck KA A KA A AA ZAZ ZX AX A A X A ZAZ AX A A KA ZA ZK AA KA ZA XK AZ A AZ ZA kk AKA A KA KA Mk kA ko ko kc ko ko ck KKK Global package definition kk Sos isla as 9 ozehoncem sie note This definition is used for device type settings User Package KAZ ck ck kck AKA A KA KHK A A Z A A AA ZAZ kck AXA A KA KK A X A A K KAZ ck K KS Code fdefine L3 PACKAGE 4 4 3 Multiple Instances Resource Activation For each instance of a resource there is an individual definition for activation In the following example there is shown the activation definitions for the Multi Function Serial Interface Multi Function Serial define L3 PERIPHE define L3 PERIE define L3 PERIE define L3 PERIE define L3 PERIE define L3 PERIE define L3 PERIE define L3 PERIE ABLE as Es
76. ck kk kk Ck Ck ck KA A KA A AA KA ZAZ A X A A XZ A ZAZ AX A A KA ZA AK AA KA ZA XK AZ A AZ ZA ZAZ AKA A KA KA A Mk ko ko kc ko ko ko kokok brief User ADC input configuration kk Number ot analog input pins 5069 A define L3 ADC CHANNELS 16 Do not specify a number higher than the maximum available analog inputs 4 4 6 2 ADC FIFO Depth The number of ADC scan conversion FIFO not priority scan FIFO is specified by the following definition Fujitsu Semiconductor Europe GmbH 29 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 4 L3 Main Files Ck ck ckck kck AKA ck KA KAZ A K A A Z A Ck A ZK AXA A K A KAZ A ko A A KA ZAZ ck ko A A KA Ck ck ck ko AKA A ck ck ck ko ck ko Sk A ko ck ck ck ck ko Sk ke Sk kk A ko brief User ADC FIFO depth configuration kk xA DADE Scan conversion ERRO depto Ito kG KKK CK Ck Ck Ck Ck Ck Ck Ck Ck KKK KKK KKK KKK k kc k kc k kc k kc k kk KKK KKK KKK k kk KKK KKK ck k ck ck KKK KKK define L3 ADC FIFO DEPTH 16 Do not specify a number higher than the maximum available analog inputs 4 4 6 3 Number of DMA Channels The number of available DMA channels has to be specified If a device does not support DMA it is not needed to set this to definition to O because it is overruled by the device type definition ck ck ck ck ck ck ck kk ck ok ck ck ck ck KKK ck ck KKK KKK KKK KKK KKK Ak KK KKK KKK KKK X AA A AX AX X A kA k kA AX X AAA kv ko
77. config t pfnPllStabCb is defined and the according interrupt is enabled Callback Function void PllStabilizedCallback void 5 5 21 SubClockStabilizedCallback This function is called if stc c1k config t pfnScoStabCb is defined and the according interrupt is enabled Callback Function void SubClockStabilizedCallback void 5 5 22 MainClockStabilizedCallback This function is called if stc clk config t pfnMcoStabcbis defined and the according interrupt is enabled Callback Function void MainClockStabilizedCallback void 5 5 23 HookFunction This function is called between SLEEPDEEP 1 and wrFI if stc clk config t pfnHook defined Hook Function void HookFunction void 5 5 24 Example Code The following code excerpts shows some applications of using the clock driver 5 5 24 1 Clock Configuration Assume the following example configuration for the examples in the following sub chapters The PLL values were chosen for a MB9BF50x device Fujitsu Semiconductor Europe GmbH 81 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include Mick hm void ClkHookCallback void Some action function ste clkicontig t KCON ELGE kConfig kConfig kConfig Commence kConfig kConfig KC Once kConfig kConfig kConfig kConfig kConfig k
78. disabled 5 17 4 Flashtiming SetFlashSyncDown This function allows to slow down the Flash access with synchronous wait states for power management Note this function is not available for Device Types 6 8 and 9 Prototype en result t Flashtiming SetFlashSyncDown en flashtiming flash sync down t enFlashSyncDown Parameter Name Description Number of Wait States Possible enumerators are e FlashWaitO e FlashWaitl e FlashWait3 e FlashWait5 e FlashWait7 in enFlashSyncDown Return Values Description Ok Flash wait state was set successfully ErrorInvalidParameter Wrong enumerator used MCU AN 300412 E V14 144 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 17 5 Flashtiming SetFlashWait This function allows to insert wait states which may necessary for higher HCLK For Device Type 2 and 4 also the Flash Accelerator has to be enabled by this function Note this function is not available for Device Types 6 8 and 9 Prototype en result t Flashtiming SetFlashWait en flashtiming flash wait mode t enFlashMode Parameter Name Description Wait State Mode Possible enumerators are e Flash0CycleMode All Device Types FlashAcceleratorMode Type 2 4 Flash2CycleMode Type 0 5 FlashPreFetch20More Type 6 8 for HCLK 220 MHz FlashPreFetch20To
79. done ErrorInvalidParameter pstcDt NULL 5 6 7 Crc ReadResult This function returns a 32 bit value regardless of a valid pointer to the CRC instance anyhow Prototype hine S Cia ReecRkecult ete Cem 16 Scere Parameter Name Description ips teen CRC instance pointer Return Values Description a e CRC result value 5 6 8 Example Code The following code excerpt examples shows how to handle the CRC functions 5 6 8 1 Configuration The following example configuration may be used for the example code below fineikude cerca function stcCrcConfig enMode CRC32 used stcCrcConfig bUseDma II see below StteGreContig brinalxor OE No final XOR stcCrcConfig bResultLsbFirst SE Result in MSB first stcCrcConfig bResultLittleEndian TRUE Result little endian used stcCrcConfig bDataLsbFirst SB Data MSB Es stcCrcConfig bDataLittleEndian TRUE Data little endian used stcCrcConfig u32CrcInitValue OxFFFFFFFF Start value The following code excerpt shows example data which is used for CRC here const uint32 t u32ConstData 64 0x6393B370 OxF2BBAFCO 0x6D793D2C 0x508B2092 0xD663962A 0x67CB9FA2 0xCD318688 0x393DAA84 l MCU AN 300412 E V14 88 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 6 8 2 CRC without DMA The CRC can be fed without DM
80. in this case Dna DeInit Channel has to be called before to unlock the channel for a new configuration Dma Set ChannelParam and Dma Del nit ChannelParam perform the same functionality as Dma Set Channel and Dma DeInit Channel instead of configuration usage Here direct arguments are used Note Setstc dma config t ul6TransferCount to Number of Transfers 1 5 10 1 Configuration Each DMA channel has the same configuration structure of the type of stc dma config t Type Field Possible Values Description E TRUE Enable DMA channel boolean t bEnable FALSE Disable DMA channel gt TRUE Pause of a DMA channel boolean t bPause E FALSE Normal function resume Rene n Trigger bit for software Bane dE Di transfer only set by rigger Enable Dma Channel en dma idreq t enDmaIdrq see below see below Bio u8BlockCount Block counter nm ul6Transfer _ Transfer count Number of Count transfers 1 DmaBlockTransfer Block transfer en dma enTransfer n k Bel nat p E us DmaDemandTransfer Demand transfer ha eae Dma8Bit 8 Bit transfer tm dk Dmal6Bit 16 Bit transfer transferwidth t Wdith Dma32Bit 32 Bit transfer EE u32Source M DMA source address Address O E u32 DMA destination address Destination MCU AN 300412 E V14 102 Fujitsu Semiconductor Europe GmbH
81. in bus off state CanWarning At least one error counter has reached error warning limit of 96 5 4 12 Example Code The following code excerpts shows some applications of using the CAN driver 5 4 12 1 CAN Configuration and Settings Assume the following configuration and Settings also for the further example code Note that it is assumed that the callback functions CanStatusCb and Can ErrorCb exist Fujitsu Semiconductor Europe GmbH 69 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include cone function EC CEN Eeer tc can msg data t sketantonkig stcMsgData tc can msg t tc can msg t ESPECIAS cc can msg id t ce can msg adi it tel ecan msg data t4 stcMsgld stcMsgBufferl stcMsgBuffer2 pstcCan pstcMsgId pstcMsgData Beete EE TEE ERO STRUCT ERO STRUCT ERO STRUCT ERO STRUCT ERO STRUCT uint32 t u32MsgIdMaskl uint32 t u32MsgIdMask2 pstcCan pstcMsgId pstcMsgData pstcMsgBufferl pstcMsgBuffer2 tecaneonfsgei LOOK Bits tcCanConfig EcCanContag tetancontig e Came onis EcGanCGon tug TX burier stc s s CC essage tcMsgData tcMsgData au8 tcMsgData au8 tcMsgData au8 tcMsgData au8 tcMsgData au8 tcMsgData au8 tcMsgData au8 au8 Qu o ou uu Sue u EE biter SEC u32 sgIdMaskl stc cann t
82. lt lt lt c lt lt zz 221 5 22 9 Qprc SetPositionRevolutionCountCompare eee 221 5 22 10 Qprc_SetMaxPositionCount cvvicosnrs Rep ER EI n CERE CREER EUR RAE 222 5 22 11 pre GelPositian GC OUDn uz ucine aaa ctetu na cop dat nad n lb de u rage 222 5 22 12 pre DORE Vol GU id rr m 222 5 22 13 Qprc_GetRevolutionCountCompare lt lt lt 222 5 22 14 Qprc_GetPositionRevolutionCountCompare 4 222 5 22 15 Qprc_GetMaxPositionCount EE 223 Fujitsu Semiconductor Europe GmbH 13 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents 5 22 16 Qprc GetbostionrevolutonCount ue 223 5 22 17 CountlnversionOallbaek inu ia 223 5 22 18 Feld EA 224 SEG uli eT PE 224 5 22 20 UndeflowCallbaok raria tan ttt dida 224 5 22 21 Fechter TTL eege 224 5 22 22 PcMatchCallback usando puteis us br ua ici Up Una M tail 224 5 22 23 PeMatchRoMatcneallbask meieriet ease 224 5 22 24 OutrangeCallback EE 224 5 22 25 Example Code eee een nenene 224 5 23 RAMCODE RAM prs e r ennet 228 5 23 1 NMI Handling e 228 5 24 RESET Reset Cause eld 230 zo WEE cu que ccc 230 5242 Reset GetCause L uassmiimsniresiensusoinsieneinidvihhubiie ende 230 5 24 3 Example Code eee eee nenene nen 230 JE ADHI Nie 232 5 25 1 Configuration Eer 232 5 25 1 1 RTC Configuration sionista 232 5 25 1 2 Alarm Register Enable Strucultre 2 233
83. of external Interrupts z eee eee eee 30 4 4 7 Special ActiVAtorS eee eee Hee 30 4 4 7 1 PPG 16 16 Mode eee eeeeeeee eee eee eee ent 30 4 4 7 2 Number of ADC Channels sss 31 4 4 7 3 ADC FIFO depib 31 4 4 7 4 Number of External Interupts 31 4 4 7 5 No Flash RAMCODE Compiler Switch 31 4 4 7 6 Flash Routines DMA Hat 32 4 4 7 7 RAMCODE NMI Vector Handle ee 32 4 4 7 8 NMI RAMCODE Vector Address rrrnnrrnnrrnrrrnnrrnnrnnrnrnnnnnnnnnnn 32 4 5 File miermuptsc ENEE 33 4 6 File miermupteh AE 34 LAM NIE 34 4 8 File ramcode h eee 34 5 L3RESOURCE DRIVER API 2 ecu ue eon ean nno i xa P e uo En ine DE sami a exo osa Ro Din ER DER ERo RARE DA 35 liie Y 35 5 2 ADC Analog Digital Converter Module dini rae ponere tuac pa ege nr Ee E Reate EE 37 5 2 1 Interrupt Scan Conversion sse 37 5 2 2 DMA Scan ConversioOn sss nnne 38 5 2 3 Configuration Structure sio 38 524 USO 41 5 2 5 Ade DEI sutor EL pi ER n kikki m oo Cras kika tka ee 41 5 2 6 ADE InggersStari RE neet 41 5 2 7 ARMS im T 41 5 2 8 Adc_StoreData RE 42 52 9 Ad Ann OE ET oo 42 5 2 10 AGC PurgePro FO us 42 B AE GARE RETOUR EET 43 5 2 12 CallbackAdc seis crane dd 43 5 2 13 p ce 43 5214 o tac E 44 5215 Pr mertualbadfad husmennene pai 44 5 2 16 Example Code nn nnnnnnnnennnnn nanna nenn anneanne 44 5 2 16 1 Polling Mode GP 44 5 2 16 2 Interrupt Mode 8 Bit ooooccccnccccccccoconcncnnnnncnonononcccnncnnnnnnn
84. of resource 1 e resourceabbreviation1 h Configuration structures and API function prototypes of drivers of resource 1 resourceabbreviation2 C see above resourceabbreviation2 h see above For green files user settings are needed blue files may be edited by the user and orange files should not be changed by the user As can be seen above the library has 8 common used files 3 c 3 h I3 user h interrupts c interrupts h ramcode c ramcode h and base types I3 h For a certain resource s driver collection 2 files are needed resourceabbreviation c and resourceabbreviation h where resourceabbreviation is the abbreviation of the resource such as dt for Dual Timer m s for Multi Function Serial etc 2 2 Characteristics The L3 functions for the resources have the following characteristics e Each function of a resource driver is existing only once in the ROM Flash memory regardless of the number of resource instances It uses a so called handle to the instance e Each function of the driver uses a configuration data structure per instance which has to be defined in the user application e Most API external functions have a return value at least just en result t Ok Each resource driver provides an Init and a De Init function If the resource driver uses interrupts the interrupt service routine s is are part of the driver If it is reasonable callbacks to a user function are provided MCU AN 300412 E V14 18
85. pstcMfs Pointer to MFS instance Return Values Description Ok MFS de initialized ErrorInvalidMode MFS not in Lin master or slave mode ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved 5 20 29 TxCallback This function is called if stc m s config t pfnTxCallback is defined Fujitsu Semiconductor Europe GmbH 173 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Callback Function vordi r xCa back vond 5 20 30 RxCallback This function is called if stc_mfs_config_t pfnTxCallback is defined Callback Function On d SG vowels 5 20 31 ErrorCallback This function is called if stc m s config t pfnErrCallback is defined Callback Function NOU CI PATSISOSG ebook o c Error enumerators will be provided in future versions of the LLL 5 20 32 LinBreakCallback This function is called if stc mfs lin config t pfnLinBreakCallback is defined Callback Function void LinBreakCallback void 5 20 33 LinTxCallback This function is called if stc mfs lin config t pfnLinTxCallback is defined Callback Function void LinTxCallback void 5 20 34 LinRxCallback This function is called if stc mfs lin config t pfnLinRxCallback is defined Callback Function void LinRxCallback void 5 20 35 Example Code
86. represents enabling channel 0 MSB Select Ise dE represents enabling channel 31 a AdcModeScan ADC configured to scan conversion ON AGE enConver Conversion conversion d T moda t sionMode AdcModePriority ADC configured to priority conversion m Conversion Uc SNR Sampling time See peripheral uint8 t mc manual analog part for correct settings AdcSamplingTime Sampling time multiplier Multiplier en adc all Sampling time multiplied by 1 sampling enSampling A Sampling time multiplied by 4 me me 8 Sampling time multiplied by 8 multipliers NE UG Sampling time multiplied by 16 t uud Sampling time multiplied by 32 Od Sampling time multiplied by 64 dl 248 Sampling time multiplied by 128 256 Sampling time multiplied by 256 GER F divisi tio fi uint8 t Comparison ue Mn or TimeDivider comparison time bSingle TRUE Single conversion boolean t A Conversion FALSE Repeated conversion bReset TRUE Reset buffer counter s at end of boolean t Buffer conversion for repeated conversion Counter FALSE Does not reset buffer counter s deme EE EE Adc12Bit ADC results in full 12 Bit Resolution Adc8Bit ADC results in 8 Bit Si Ela me enUse AdcPolling Polling mode for result interrupts Interrupts AdcInterrupts Interrupts used dma t Dma AdcDma DMA used if provided by MCU pu8Channel Buffer 5 ae ou ed dads list to channel buffers 8 bit L3 ADC resolution CHANNELS pul6Chan
87. set to 13 ON Possible values are SON NMI is pre serviced in RAM vector code lt OR BR NMI S not hangied n RAM routines Fk ke Ae eA k Ck k Ck k Ck Ck kCk Ck k kCk Ck KKK KKK kCk Ck KKK KKK KKK kCkCk Ck Ck kCk Ck kCk ck k ck k ck k KKK KK KKK define L3 NMI RAM VECTOR HANDLE L3 ON 4 4 7 8 NMI RAMCODE Vector Address This macro defines the location of the NMI vector in RAM Take care of correct address choice ck ck ck ck ck ck ck kk ck KKK KKK ck ck ck KKK KKK KKK KKK kk ck Ak KK KKK KKK KKK KKK A X AZ AX AX k A kk A A ck ko kv ko ko kk ko kv ko ko ko brief NMI RAM vector address Only used if L3 NMI RAM VECTOR HANDLE UE L3 ON L3 FLASH DMA HALT L3 ON and RAMCODE used dee Used for remapping VTOR to RAM area Must be defined by user Note that the last 6 bits are always treated as 0 A global varibale u32L3NmiVectorAddress for the RAM NMI vector is placed at this address 8 Nattention Be careful by choosing the address It must not interfere with the RAM vector table if Debug build is used The address must 2 be less than 0x20000000 and bigger than the bottom of the RAM Sa There is no automatic plausibility check KKK KK KKK KKK kk ck kc KKK KKK KKK KKK KKK KKK k kk KKK KKK KKK KKK ck k ck k ck k ck k ck ck ck KKK KKK define L3 RAM VECTOR TABLE ADDRESS Ox1FFFFFO00 MCU AN 300412 E V1
88. sue mueca ll SECC Parameter Name Description iso Site e Ib RTC instance pointer Return Value Description RtcRinClockNoOperation RIN clock not operating RtcSubClockSelected Sub Clock is selceted Main Clock is selceted R RtcMainClockSelected R RtcInvalidInstance PSECRECH NURE MCU AN 300412 E V14 240 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 25 12 Rtc TimerSet This function sets the mode and Timer value of the RTC Timer The RTC has to be initialized before to use this function properly Also use the Timer Interrupt enable by Rtc Init Prototype sm resule Rec Deene volatile ste ren ic PSECREC STe ree timar Contig ce Son Parameter Name Description in pstcRtc RTC instance pointer in pstcConfig Pointer to RTC configuration structure Return Value Description Ok Time mode successfully set ErrorlInvalidParameter pstcRtc NULL e pstcConfig NULL 5 25 13 Rtc_TimerStart This function starts the Timer of the RTC Timer The RTC has to be initialized before to use this function properly Also use the Timer Interrupt enable by Rtc Init Prototype am result CHM MOOC volerile sue mue ic PSLECRECG Parameter Name Description in pstcRtc RTC instance pointer Return
89. t Type Field Possible Values Description neis E u32LoadValue Timer interval TRUE Enables Watchdog Reset bool E bR tEnabl p ae en carga TLSE Disables Watchdog Reset E TRUE Enables Watchdog Interrupt bool bIrgEnabl E Duag IESU FALSE Disables Watchdog Interrupt TRUE Initialize reset NVIC registers 1 TouchNVIC pos eanet Due FALSE Do not touch NVIC registers fuse oler pfnCallback Pointer to Watchdog callback function Only valid for Hardware Watchdog 5 28 2 Wdg InitSwWdg This function sets up the Software Watchdog according its configuration The to enable the Software watchdog stc wdg sw config t bIrqEnable must be set to TRUE MCU AN 300412 E V14 254 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype en result t Wdg InitSwWdg stc wdg config t pstcConfig Parameter Name Description in pstcConfig Pointer to Watchdog configuration structure Return Values Description Ok Setup sucessful ErrorlInvalidParameter pstcConfig NULL 5 28 3 Wdg FeedSwWdg Feeds the Software Watchdog and restarts its interval Prototype void Wdg FeedSwWdg void 5 28 4 Wdg InitHwWdg This function sets up the Hardware Watchdog according its configuration The Hardware Wa
90. t ACE COonversiongrartel volen ete coca CPS CC Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok Conversion finished OperationInProgress Conversion ongoing ErrorInvalidParameter pstcAdc NULL 5 2 8 Adc StoreData This function stores a conversion data into the correct channel buffer Prototype sm result t Ade SroreDatal volatile sue aden us PerCoACE Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok Data stored successfully TOT Butter PAM Data buffer full data not stored ErrorlInvalidParameter pstcAdc NULL 5 2 9 Adc PurgeFifo This function purges the scan conversion FIFO and rejects all data It should be called in case of an error Prototype em result t der UO SEO volewilo sue acea SECC Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok Scan conversion FIFO purged ErrorlInvalidParameter pstcAdc NULL 5 2 10 Adc PurgePrioFifo This function purges the priority scan conversion FIFO and rejects all data It should be called in case of an error MCU AN 300412 E V14 42 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype em rosule t degrurgerrio ro volar
91. the MFS MCU AN 300412 E V14 164 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype SMS STU ES ESO EC SEC STO SEC S Ghear jE PSZ SEC boolean t bWait Parameter Name Description in pstcMfs Pointer to MFS instance in pszString Pointer to string buffer Must be 0 terminated TRUE Synchronously wait until reception complete in bWait 3 y y p p FALSE Do not wait Return Values Description Ok String successfully transmitted ErrorInvalidParameter e pstcMfs NULL 9 PSaSitrume NGG pstcMfsInternData NULL Instance could not be resolved 5 20 15 Mfs_ReadString Reads an EOL terminated string from the MFS module a synchronously The character buffer provided by Mfs ReadString pcData is used to copy the received data The free size of the buffer must be sufficient to take all data Mfs Read pcData of length Mfs Read ul6MaxChars 1 null Terminator After Mfs Read ul6MaxChars data is received the function will return immediately without terminating the buffer If the provided terminator is detected the function will null terminate the buffer and return Notes e No error checking is done while reading from the MFS channel e Given character array will be null terminated by the function itself The reception FIFO is disabled because of random number of characters be
92. underflow ode bPpgA anm puce nA re TRUE Interrupt on PPLH4 underflow CECR s FALSE Interrupt on PPLL4 underflow ode nimele e ul6PpgOLow PPGO low count 16 Bit Mode nimee E u8PpgOLow PPGO low count 8 8 8 Bit mode uint8 t u8PpgOHigh PPGO high count 8 8 8 Bit mode uint16 t clerus eph PPGO high count 16 Bit Mode u8Ppg0 uint8 t aka PPGO low count 8 8 8 Bit mode 8Ppg0 uint8 t P NA e PPGO high count 8 8 8 Bit mode High see above for PPG2 nimele ie ul6Ppg4Low PPG4 low count 16 Bit Mode nimee ie u8Ppg4Low PPGA low count 8 8 8 Bit mode Ginco jE u8Ppg4High PPGA high count 8 8 8 Bit mode uintl6 t boogie PPG4 high count 16 Bit Mode m u8Ppg4 uint8 t du Pad PPG4 low count 8 8 8 Bit mode 8Ppg4 uint8 t Vois rice m PPG4 high count 8 8 8 Bit mode High uintl6 t ul6Ppg6Low PPG6 Prescaler in 16 16 Bit Mode uintl6 t ul6Ppg6High PPG7 Prescaler in 16 16 Bit Mode en mft ppg enPpg0 MftPpgTiming Trigger by Timing Generator circuit Fujitsu Semiconductor Europe GmbH 193 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API CELSE E Trigger Generator Start delay MftPpgGate Trigger by GATE signals of MFT Signal MftPpgTrigger Trigger by TRG register writing SW Register trigger SM CP O enPpg2 creig mo
93. version 1 7 6 9 HDMI CEC Remote Control Reception The HDMI CEC Remote Control Reception is not implemented in the recent LLL version 1 7 Future versions of the LLL will cover this functionality 6 10 Supported Peripheral Instances The following table shows the numbers of available instances of supported peripherals Single built in resources which are not real peripherals like Clock Module Deep Standby Modes or Low Voltage Detection are not listed here Maximum A Peripheral Number of Address Pointers of Instances Instances Analog Digital Converter 3 ADCOP ADC ADE 3m0 Bri BIZ BIS Multi Function Timer MFTO MFT1 MFT2 Quadrature Position and Revolution Counter Universal Serial Bus CERCO OB Cil Base Timer 8 BT4 BT5 BT6 BT7 Controller Area Network 2 CANO CAN1 Cyclic Redundancy Check 1 CRCO Digital Analog Converter 2 DACO DAC1 Dual Timer 1 DTO Ethernet Macro 2 EMACO EMAC1 External Ethernet PHY 32 E MFSO MFS1 MFS2 MFS3 Multi Function Serial 8 MFS4 MFS5 MFS6 MFS7 3 2 2 USBO USB1 MCU AN 300412 E V14 260 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 7 Additional Information 7 Additional Information Information about FUJITSU Semiconductor s Microcontroller can be found on the following Internet page http mcu eme
94. 1 7 Activated ENABLE Deactivated ENABLE HD MCU AN 300412 E V14 28 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 4 L3 Main Files Always use keywords L3 ON or L3 OFF for this purpose Carefully check the activation before usage whether your device supports a peripheral and especially a certain instance because the L3 does not check for availability by device name and package 4 4 4 Single Instances Resource Activation Any resource which only has a single instance is defined the same way like multiple instance resources The resource gets an index 0 for this purpose The MB9BF50x series only has one Dual Timer Therefore the definition looks like the following TUNE 0 Instace define 4 4 5 Interrupt Level Definition The interrupt level definitions must be set by the user It may look like the following for e g the Multi Function Serial User Levels 1 MFS1 RX 4 4 6 Numerical Definitions Some feature amount e g number of ADC inputs are not handled by the L3 itself because it depends on the device itself and the user demands Therefore they have to be set by the user 4 4 6 1 Number of ADC channels The number of ADC channels is specified by the following definition Ck ck ck
95. 14 Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 21 1 1 Free Run Timer and Output Compare Unit Configuration The FRT and OCU share the configuration of the type of stc mft frt ocu config t Type Field Possible Values Description Mobel FRTO count clock cycle PCLK DEET FRTO count clock cycle PCLK 2 MftPclk4 FRTO count clock cycle PCLK 4 MftPclk8 FRTO count clock cycle PCLK 8 cenimit ie CE enClock0 MftPclk16 FRTO count clock cycle PCLK 16 Me C2 FRTO count clock cycle PCLK 32 MftPclk64 FRTO count clock cycle PCLK 64 MftPclk128 FRTO count clock cycle PCLK 128 MftPclk256 FRTO count clock cycle PCLK 256 cenimit Mello CE enClockl see above see above for FRT1 Sim mie Clock t enClock2 see above see above for FRT2 MftUpCount FRTO up count mode en mft mode t enMode0 MftUpDownCount FRTO up down count mode en mft mode t enModel see above see above for FRT1 en mft mode t enMode2 see above see above for FRT2 i Be TRUE Enables TCCPO buffering boolean t BE p 3 FALSE Disables TCCPO buffering Enable i Bak TRUE Enables TCCP1 buffering boolean t Buffer FALSE Disabl P1 buffer Enable isables TCCP1 buffering I cede TRUE Enables TCCP2 buffering boolean t Bukken
96. 4 32 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 4 L3 Main Files 4 5 File interrupts c The interrupts c file contains all first level service routines interrupt vectors of start code The code also handles possible shared interrupts check the occurrence bit s IRQMON first and then call the driver s own service routines This file should not be changed by the user The following code excerpt shows how a shared interrupt is treated DT ISR not shared with QPRC if L3 PERIPHERAL ENABLE QPRCO L3 ON amp amp V L3 PERIPHERAL ENABLE OPRC1 L3 ON amp amp L3 PERIPHERAL ENABLE DTO L3 ON void DT Handler void DtIrgHandler0 stc qprn t amp DTO amp m_astcDtInstanceDataLut DtInstanceIndexDt0 stcInternData QPRC ISR not shared with DT elif L3 PERIPHERAL ENABLE QPRCO L3 ON Wt L3 PERIPHERAL ENABLE OPRC1 L3 ON amp amp L3 PERIPHERAL ENABLE DTO L3 ON void DT Handler void dif L3 PERIPHERAL ENABLE QPRCO L3 ON if FM3_INTREQ gt IRQ06MON amp IRQ06MON QPRCO BITMASK 12 0 OprcIrqHandler stc qeren t amp QPRCO amp m astcOprcInstanceDataLut OprcInstanceIndexOprc0O stcInternData endif dif L3 PERIPHERAL ENABLE QPRC1 L3 ON if FM3 INTREQ gt IRQ06MON amp IRO06MON QPRC1 BITMASK 1 2 0 OprcIrqHandler stc qprcn t amp QPRC1 amp m astcOprcInstanceDataLut QprcInstanceIndexQprc0 stcInternData
97. 40 Type 9 for HCLK 220 MHz and lt 40MHz e FlashPreFetch40More Type 9 for HCLK 240 in enFlashMode MHz Return Values Description Ok Flash wait state was set successfully ErrorInvalidParameter Wrong enumerator used 5 17 6 Flashtiming SetWorkFlashWait This function allows to insert wait states for a Work Flash area Note this function is only available for Device Types 4 and 5 Prototype en result t Flashtiming SetWorkFlashWait en flashtiming work flash wait mode t enFlashMode Parameter Name Description Wait State Mode Possible enumerators are WorkFlash0CycleMode 0 WS Type 4 5 WorkFlash2CycleMode 2 WS Type 4 5 WorkFlash4CycleMode 4 WS Type 5 only in enFlashMode Return Values Description Ok Work Flash wait state was set successfully ErrorInvalidParameter Wrong enumerator used Fujitsu Semiconductor Europe GmbH 145 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 17 7 Example Code include flashtiming h function Device Types 2 4 en flashtiming flash buffer status t enFlashStatus enFlashStatus Flashtiming GetFlashBufferStatus Flashtiming EnableFlashBuffer function Device Types 0 17 2 3 4 5 Y Flashtiming SetFlashSyncDown FlashWait3 function3 Device Types 0 2 4 6 8
98. 5 17 Clk_EnableMainClock This function easily enables the Main Clock No configuration is needed For stabilization wait time Clk WaitForSubOscillator has to be called afterwards Prototype en result t Clk EnableMainClock void Return Values Description Ok Main Clock enabled 5 5 18 Clk_DisableMainClock This function easily disables the Main Clock No configuration is needed Prototype entire sulla eI episaoteMaumnelteek voe Return Values Description Ok Main Clock disabled 5 5 19 Clk Setlrg This function enables or disables the clock stabilization interrupts according configuration Note Because of shared vectors for clock interrupts the parameter bTouchNvic defines if the NVIC registers shall be touched or not Prototype Sm resule t Clk Serulre sue Clk comrls Es Ppsuvetomnulg boolean t bTouchNvic Parameter Name Description fin psveCont ig Clock configuration parameters TRUE Touch NVIC registers at function call FALSE Do not touch NVIC registers at function call itn PoLowehnNvie Return Values Description Ok Interrupts have been set ErrorInvalidParameter pstcConfig NULL MCU AN 300412 E V14 80 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 5 20 PIIStabilizedCallback This function is called if stc clk
99. 6 5 12 12 EG C POE PO OE PRE PO E tree POE PE O er treet reer verter 116 5 12 13 Example Code 0000 een een en nn nenene EEEE 116 5 12 13 1 Configuration IritialiZeltGri sra 117 5 12 13 2 Initialization Parameter Change and De Initialization 118 EMAC ETHPHY Ethernet Macro Ethernet PHY 119 EXINT External Interrupts and NM 120 5 14 1 Configuration Structures M 120 5 14 1 1 External INterruptS eee eee een nn nn 120 5 14 1 2 None maskable Interrupt NMI z eee 121 MESI UU TT 121 5 14 3 Exint_Delnit RE O ea 121 5144 Ein Enable Channel spas EE 121 5 145 Exint DisableChann l Jer noct nat nine pics irte ean 122 5 14 6 ENN 122 5147 Part EU name 122 Fujitsu Semiconductor Europe GmbH 9 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents 5 15 5 16 5 17 5 18 5140 BINDE idc 123 5 14 9 Nl MER ee 123 5 14 10 Example Code eee een nenene 123 5 14 10 1 External Interupnts 123 5 14 10 2 NMI socias 123 EXTIE External Bus JEE eege 125 5151 Configuration Structure cid ti n rail 125 5152 AA A 127 5 15 3 Br Deli cm EE 127 5154 P Bland EIERE Keeser gg EEEdae 127 5 15 5 JExur JNand SEMEN lucieron 127 5 15 6 Exif Nand ReadDal l eain taion ute xn tu daekunk tence kama tati 128 5 15 7 Extif_Nand_WriteData sveket 128 5150 Pr Nano Be E PR M He 128 5 15 9 Example Codes eee eee nenene nene 129 SAS SIONIS ose a no n O OE UL EM 129 5 15 9 2 NAND TE 130 FLASH Flash Era
100. 7 7 WcCallback On a period of 1 second a callback function is called if its pointer in the configuration is unequal to NULL Callback Function void WcCallback void 5 27 8 Example Code The following code excerpt gives an example of how to use the WC driver MCU AN 300412 E V14 252 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include wc h SUCEWE CONENG ue sieWeconfig struct tm stcCalendar void WcCallback void uint32_t u32CurrentSecond Wc GetTime volatile stc_wcn_t amp WCO u32CurrentSecond stcCalendar tm_sec Do something function Stc wen t pstcWc NULL tcWcConfig enPrescalerDiv WcPrescalerDiv1000ms tcWcConfig bEnable TRUE tcWcConfig u8SetSecond bk tcWcConfig u8SetMinute 4 tcWcConfig u8SetHour 9 tcWcConfig u8SetDay 15 tcWcConfig u8SetMonth Wc September stcWcConfig u8SetYear Wc Year 2011 stcWcConfig i8SetIsdst 0 stcWcConfig pfnCallback amp WcCallback stcWcConfig pstcCalendar amp stcCalendar if Ok Wc Init volatile stc wcn t amp WCO amp stcWcConfig TRU pstcWc stc wen t sWC0 Wc SetTime pstcWc amp stcWcConfig Do something Fujitsu Semiconductor Europe GmbH 253 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 28 WDG Software and Hardware Watch Dog Type Definition
101. 8 uintl6 t ul6ReadCount stcLinConfig2 enLinMode LinSlave stcLinConfig2 bExtWakeUp FALSE stcLinConfig2 u32DataRate stcLinConfigl u32DataRate stcLinConfig2 enLinStopBits stcLinConfigl enLinStopBits stcLinConfig2 enLinDelimiterLength stcLinConfigl enLinDelimiterL stcLinConfig2 bLinBreakIrqEnable TRUE stcLinConfig2 pcLinTxBuffer cTxBuffer2 stcLinConfig2 ul6LinTxBufferSize 8 stcLinConfig2 pcLinRxBuffer cRxBuffer2 stcLinConfig2 ul6LinRxBufferSize B stcLinConfig2 pfnLinBreakCallback amp Mfs4LbrCallback stcLinConfig2 pfnLinRxCallback amp Mfs4RxCallback2 stcLinConfig2 pfnLinTxCallback NULL if Mfs Lin Init stc mfsn t amp MFS4 amp stcLinConfig2 pstcMfs stc mfsn t amp MFS4 Setup pointer to USART instance while 0 u32LinBreak Wait for Lin master s break u32LinBreak 0 Prepare read of Lin master task u32CountRxCb 0 Mfs Read pstcMfs char amp au8RxBuffer amp ul6ReadCount 4 FALSI Wait for all data read while u32CountRxCb 4 Process data while 0 u32LinBreak Wait for next Lin master s break u32LinBreak 0 MCU AN 300412 E V14 184 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prepare read of Lin slave task u32CountRxCb 0 Mfs Read pstcMfs char amp au8RxBuffer amp ul6ReadCount 2 FALSE Prepare slave task data au8TxBuffer
102. A configuration structure Return Values Description Ok DMA channel successfully cleared nvalidParameter ROMA e pstcAdc NULL e Invalid configuration 5 10 7 Dma Set ChannelParam This function enables disables pauses or triggers a DMA transfer according to the settings in the configuration bits for EB Enable PB Pause and ST Software Trigger MCU AN 300412 E V14 104 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype en result t Dma Set ChannelParam uint8 t u8DmaChannel boolean t bEnable boolean t bPause boolean t bSoftwareTrigger Parameter Name Description in pstcConfig Pointer to DMA configuration structure in bEnable TRUE Enables channel FALSE Disables channel in bPause TRUE Pauses a channel FALSE Starts resumes a channel in bSoftwareTrigger TRUE Triggers a channel FALSE Does not trigger a channel Return Values Description Ok Setting finished successfully 5 10 8 Dma Delnit ChannelParam This function clears a DMA transfer by channel parameter Prototype en result t Dma DeInit ChannelParam uint8 t u8DmaChannel Parameter Name Description in u8DmaChannel DMA channel to be cleared Return Values Description Ok DMA channel cleared successfully
103. A usage as shown in the next code excerpt Except for bUseDma the configuration 5 6 8 1 is used include Veret function uint8 t u8Count SECNCECRCOMEAG IE Sic Cre conil L3 ZERO STRUCT stcCrcConfig stcCrcConfig bUseDma FALSE No DMA used Test 32 bit pushing LE Ok Ee EE EE senke SERGE Or seere Gong for u8Count 0 u8Count lt 64 u8Count Crec Push32 0 suctorenswt9 GEECREO cu32CconstDataj uscount r Cre DeInit stc cren t amp CRCO Return value ignored because of if case V above and same instance pointer used 5 6 8 3 CRC with DMA For usage of the DMA please refer to chapter 5 10 The following code uses CRC and DMA together Except for bUseDma the configuration 5 6 8 1 is used Fujitsu Semiconductor Europe GmbH 89 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include crc h include dma h uint32_t u32CrcResult uint8 t u8DmaFinished 0 KK KK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK A I ke kx DMA callback functions GC BRK RK Ck kk hh hh hh AKA KA AKA KA e kck kc k kc k kc k kck kc k kc k ek void Crc DmaError uint8 t u8DmaErrorCode Some error handling here void Crc DmaFinished void u8DmaFinished 1 function ste crel contigit SteCreContig stc dma config t stcCrcDmaConfig ERO STRUCT stcCrcConfig ERO STRUCT stcCrcDmaConfig
104. AK A KA ZA ZK AZ A AZ ZA ZAK A ZA A KA KA Mk Mk ko ko kc ko ko ko AA brief User ADC FIFO depth configuration kk ADC Scan conversion FIFO depth 1 to 24 KKK KK KKK KKK KKK k kCk Ck KKK k Ck k Ck KKK kk kk KKK kCkCk Ck kCkCk k KKK Ck k Ck Ck k k ck Ck ck k ck k KKK KKK define L3 ADC FIFO DEPTH 16 4 4 7 4 Number of External Interrupts With L3 EXINT CHANNELS the user determines the maximum number of External Interrupt Inputs ck ck ckck ckck AKA ck KA KAZ A K A A A A X A kk AXA A KZ A KAZ A X A A KA ZAZ AX ko A A KA ZAZ ck ko ck ko A A ZA ck ko A ko Sk A ko ck ck ko ck ko Sk k k k A Ao brief User Number of external interrupt channels Number of available EXINT channels 1 to 16 KKK KK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK k k Ck Ck k kk KKK KKK ck k ck ck KK KKK KKK define L3 EXINT CHANNELS 16 4 4 7 5 No Flash RAMCODE Compiler Switch This definition sets RAMCODE Flash routines compiling or not Note that this is an Opt Out logic by choosing L3 ON Ck ck ck ck kk kk Ck Ck Ck KA A KA A AA KA ZK AX A A Ck A Ck Ck AX A A KA ZA AK A A KA ZA ZK AZ A AZ kk kk A ZA A KA KA ZK A kc ko ko ko KKK brief User does not need Flash routines in RAMCODE Possible values are se T ON Flash routines in RAMCODE are not compiled EE ES OEREPELasmeroutvinessvmeRAMCODESaCbI Ve KCKCKCKCkCkCk kk kCkCk Ck k Ck k Ck kCkCk Ck kCkCk Ck k kCk Ck Ck kCk Ck kCkCkC
105. BT functionality Mft PpgIgbt Enable is used for enabling this This function is only available for Device Type 7 Prototype en resulte t Mice OS Sec je igor Contig pb suelos Parameter Name Description in pstcConfig Pointer to IGBT configuration Return Values Description Ok IGBT successflully initialized ErrorlInvalidParameter pstcConfig NULL pstcConfig enNoiseFilter undefined enumerator 5 21 18 Mft Ppglgbt Enable Enables PPG IGBT module This function is only available for Device Type 7 Prototype sm Ssillic Mre OSA i vote Return Value Description Ok IGBT successflully enabled 5 21 19 Mft_Ppglgbt_Disable Disables PPG IGBT module This function is only available for Device Type 7 Prototype en resulte t Mre Poget Diseblel voici Return Value Description Ok IGBT successflully disabled 5 21 20 Mft Ppglgbt Delnit De initializes the PPG IGBT module This function is only available for Device Type 7 Prototype SMAS SUM C t Mig Dogler Dermiw vorc Return Value Description Ok IGBT successflully de initialized Fujitsu Semiconductor Europe GmbH 207 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 21 21 FrtnPeakCallback This function is called if stc mft frt ocu config t pfnFrtnPeakCal
106. Bit mode the upper 16 bits are set to zero automatically Prototype uint32 t Dt ReadValueChannel volatile FM3 DTIM TypeDef pstcDt stre che Channel contig jE pstecontioj imee dE u8Channel Parameter Name Description in pstcDt Dual Timer instance pointer Hal psretonrig DT configuration parameters in u8Channel 0or1 Return Type Description uino Recent value of selected channel 5 12 12 DtCallback This function is called if stc dt config t pfnCallback is defined Callback Function vomd tealtiback i void 5 12 13 Example Code The following code excerpt examples shows how to handle the Dual Timer functions Note that because each instance of the Dual Timer has 2 channels also 2 individual callback functions have to be defined if both channels are used Although the same interrupt vector is used the driver takes care of calling the correct callback function The priority in case of simultaneous interrupt occurrence is channel 0 is prior to channel 1 MCU AN 3004 12 E V14 116 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 12 13 1 Configuration Initialization include dt h void Dt0Callback0 void some code here void Dt0Callbackl void some code here function stc dt channel config t stcDtConfig0 ste dt channel config t stcDtConfigl ERO STRUCT st
107. CAN prescaler clock 1 12 CanPreDivl5 CAN prescaler clock 1 5 CanPreDiv110 CAN prescaler clock 1 10 Note that the resulting prescaler freguency of the maximum of 16 MHz is checked via PLCK2 in Can Init ErrorInvalidParameter is returned if violated 5 4 2 Can Init This function initializes one specific CAN module with the parameters provided in the given configuration structure After initialization the CAN module has Error Status and Module Interrupt enabled and is ready to use Can Init has to be called with the parameter pstcConfig of type stc can config t the basic CAN settings automatic retransmission the CAN baudrate and the error and status change callback function can be set All values in pstcConfig have to be in valid range see can h for allowed ranges of dedicated parameters The error and status change callback functions can be NULL In this case no information of error or status changes will be reported to the API To reset and disable the CAN module the function Can DeInit has to be used The resulting CAN prescaler value is checked if it is within CAN MAX CLK normally 16 MHz Fujitsu Semiconductor Europe GmbH 63 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype Sm result e Cam Imiv velacile sue emt t pstcCan Consta sue esa co noo SiC eo Parame
108. CCP2 ACCPDN2 buffer transfer on Enable zero detection DEE Ge SS BE ADCMPO compare value Sep nimele r ES a UE E ADCMP1 compare value Cep 16A zm bilion 1 6 jE ines ADCMP2 compare value nimele e kx O E ADCMPDNO compare value ccpdn MCU AN 3004 12 E V14 196 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU bere te ha iu S E ADCMPDN1 compare value ccpdn wimnele jE ES a ME ADCMPDN2 compare value cecepan en mft adc cmp enAdcempO MftAdcCmpAdcmp ADCO start on ADCMP signal start E Start MftAdcCmpFrt02 ADCO start on ored FRT0 2 signal See above for ADC1 en mft adc cmp enAdcmp2 MftAdcCmpAdcmp ADC2 start on ADCMP signal start Start MftAdcCmpFrt02 ADC2 start on or ed FRT0 2 signal MftAdcCmp ADCO priority scan start on ADCMP en mft adc cmp enAdcmp0 AdcmpPrio signal start prio t StartPrio MftAdcCmp ADCO priority scan start on or ed Frt02Prio FRT0 2 signal See above for ADC1 MftAdcCmp ADC2 priority scan start on ADCMP en mft adc cmp enAdcmp2 AdcmpPrio signal start prio t StartPrio MftAdcCmp ADC2 priority scan start on or ed Frt02Prio FRT0 2 signal 5 21 1 6 Noise Canceler Configuration The NZCL has the configuration of the type of stc mft nzcl config t Type Field Possible Values Description ME TRUE
109. Callback void if Oprc SetRevolutionCount pstcOprc function stc met Oprc GetRevolutionCount pstcOprc OPECHOONF GE OxFFFF M stcOprcConfig QPRC configuration uint8 t uint8 t MONT RO S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S if PcOpre Contac EOD re Con ace to Op cC Onfig po Ope Of Ec OD re Con fui tcOprcConfig ECOPLCCONE TO CCOPLCCON fag EcOpre Contac Ec OD ECC Oni tcOprcConfig Ecoprneconfaige Ec OD ECC On fu ECOpreCon tag PCOPrneContE Ha te Op cC Oni ECOpre Contac ECOp Ee CONAM ECOp recon fig Eo OD IC Oni ECOpre Con ui EcOpreContug o OD Be Ong ECOprecon fag tcOprcConfig Ec OD IC On ui PCOpreCon tag ECOPLCCONE LOS EcOprecon fag PCOpre Con ELSA ECOp re Con fui EcOpreConmgn Ok Opre Init ste gpren t sQPRCO u8PosCount u8RevCount STRUCT steQpreConfig enPcMode enRcMode bSwapAinBin FALSE bRegisterFunction TRUE bGateFunction FALSE enComapreMode OprcComapreWithPosition enZinEdge OprcZinDisable enBinEdge OprcBinFallingEdge enAinEdge OprcAinFallingEdge enZinMode QprcZinCounterClear nPcResetMask OprcResetMaskDisable b8KValue E ul6PositionCount ul6RevolutionCount ul6PositionCounterCompare ul6PositionRevolutionCounterCompare ul6MaximumPositionCount bEnableOutrangeInterrupt bEnableOvrfUndfZIdxInterrupt bEnableRcMatchInterrupt b b
110. Config Pointer to DMA configuration structure Return Values Description Ok Init successfully done ErrorlInvalidParameter pstcAdc NULL e Invalid configuration OperationInProgress DMA channel already in use 5 10 3 Dma_Set_Channel This function enables disables pauses or triggers a DMA transfer according to the settings in the configuration bits for EB Enable PB Pause and ST Software Trigger Fujitsu Semiconductor Europe GmbH 103 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype em result v Dmae set Chanmmell volarcile See cme Comrie ce sc one Parameter Name Description in pstcConfig Pointer to DMA configuration structure Return Values Description Ok Setting successfully done 5 10 4 Dma Enable Enables DMA globally Prototype en result t Dma Enable void Return Values Description Ok DMA globally enabled 5 10 5 Dma Disable Disables DMA globally Prototype en resule v pnapenable vordy Return Values Description Ok DMA globally disabled 5 10 6 Dma_Delnit_Channel Clears a DMA channel Prototype sm resulte t Due Delmie Clavetoiarsl eet en Sue ohne COn 165 este song Parameter Name Description eism osiceComt ig Pointer to DM
111. Config kConfig eom kConfig kConfig kConfig lkConfig kCon fag Ek orit b b e b en enPLLOWaitTime ERO STRUCT stcClkConfig enSource bEnablePll EnableMainClock EnableSubClock nMode LpmPortHiZState enBaseClkDiv enAPBODiv enAPB1Div enAPB2Div bAPB1Disable bAPB2Disable enSCOWaitTime COWaitTime u8P11K u8P11M u8PllN DEI S Gr bScolrg bMcolrq pfnHook LK functions 5 5 24 2 Setting the Clock Assume a switched off Main oscillator and PLL The system runs it can be switched to PLL clock with the configuration above like Sec b Ost m ClkRun FALSE BaseClkDiv1 Apb0Div2 ApblDiv2 Apb2Div2 FALSE FALSE ScoWaitExp15 McoWaitExp117 PlloWaitExp19 ex E ils Ex p FALSE FALSE FALSE HookCallback MCU AN 300412 E V14 82 at HC RC oscillator Then Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API rane mde edk zo la function SECCO mS OIN ont L3 ZERO STRUCT stcClkConfig if Ok Clk SetDividers amp stcClkConfig PE EGNE 5 Eee if Ok Clk SetStabilizationWaitTimes amp stcClkConfig see above if Ok Clk SetSource amp stcClkConfig H ELE Clock d if Ok Clk SetMode amp stcClkConfig Clock Run Mode If pc arrives here function calls above work p
112. Count tcLinConfigl enLinMode LinMaster tcLinConfigl bExtWakeUp FALSE tcLinConfigl u32DataRate 19200 tcLinConfigl enLinStopBits LinOneStopBit tcLinConfigl enLinBreakLength LinBreakLengthl6 tcLinConfigl enLinDelimiterLength LinDelimiterLengthl tcLinConfigl bLinBreakIrqEnable FALSE tcLinConfigl pcLinTxBuffer cTxBuffer tcLinConfigl ul6LinTxBufferSize Er tcLinConfigl pcLinRxBuffer cRxBuffer tcLinConfigl ul6LinRxBufferSize B tcLinConfigl pfnLinBreakCallback amp Mfs6LbrCallback tcLinConfigl pfnLinRxCallback amp Mfs6RxCallback stcLinConfigl pfnLinTxCallback NULL S S S S S S S S S S S S S if Ok Mfs Lin Init stc mfsn t amp MFS6 amp stcLinConfigl pstcMfs stc mfsn t amp MFS6 Setup pointer to USART instance LIN Master Task au8TxBuffer 0 0x55 Synch Field au8TxBuffer 1 M Header no LIN meaning just test byte au8TxBuffer 2 S Data no LIN meaning just test byte au8TxBuffer 3 T Checksum no LIN meaning just test byte First Set LIN Break for master task Mfs Lin SetBreak pstcMfs Prepare LIN Master Reception Buffer Mfs Read pstcMfs char amp au8RxBuffer amp ul6ReadCount 4 FALSI u32CountRxCb 0 Write rest of master task LIN Frame Mfs Write pstcMfs char amp au8TxBuffer 4 FALSI Wait for all data read back master task while u32CountRxCb 4 MCU AN 300412 E V14 182 F
113. D EE 171 5 20 24 Mfs_Lin_SetBreak E 171 5 20 25 Mfs_Lin_SetNewBaudDivisor E 172 5 20 26 Mie Lin TransfterExBulter licitador idad 172 5 20 27 Mis Lin DisableRxlnterrupt ierra cir rana daa n ak v n k 173 5 20 28 MIS Tan Dem EE 173 JELENA EEE 173 5 20 30 oie EE cp PEE 174 5 0 TE Men 174 5 20 32 LInBreakC SER men RTT 174 5 20 33 LinTXCallback EE 174 5 20 34 NR MN M 174 5 20 35 Example Codes unna GT 174 5 20 35 1 Asynchronous Communication via Configuration 174 5 20 35 2 Asynchronous Communication via Mfs Asynclnit 176 5 20 35 3 Synchronous CornmunicallOn eter nr toan tine retain 177 5 20 35 4 IC Communication crassis tete tut tnter en nece eve 178 5 20 35 5 LIN Master communication sxocrrtaaa ario 181 9 20 35 6 LIN Slave communication E 183 5 21 MFT Multi Function TIO acosa 186 5 21 1 Configuration Structures si cotta uns loto ter ei pir mieu tiles 187 5 21 1 1 Free Run Timer and Output Compare Unit Configuration 188 5 21 1 2 Waveform Generator Configuration eee 191 5 21 1 3 Programmable Pulse Generator Configuration 192 5 21 1 4 Input Capture Unit Configuration ee 194 5 21 1 5 ADC Compare Configuration da aceti akute rad hui do adea aapus 195 5 21 1 6 Noise Ganceler COnTquIatiON cuina 197 5 21 1 7 IGBT Configuration An 197 5 21 2 Mft Init 199 5213 M DEN M 199 5 214 Mft FEN M O R O Ge A 200 5 215 IMM MSO
114. Dummy c E he Ob FE 43 Release H common E system mb9bf50x c B x source files main c Readme txt startup_mb9bf50x s HH amp usbethernetclock c usb config UsbConfig c usb middleware E UsbHostHidMouse c E UsbClassSupervisor c ES UsbDeviceClassDummy c UsbHostHidCom c UsbHostHidKeyboard c Figure 3 2 Example of L3 Directory in Workspaces Note that not all files are listed here for page space reasons In some cases the used IDE loses the device configuration In this case adjust the used MCU in the projects settings MCU AN 300412 E V14 22 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 3 Using L3 in own Application Projects 3 2 Adjust L3 to used FM3 Device For announcing the used FM3 derivative an adjustment has to be done Set the device name in 3 user h described in chapter 4 1 1 The exact definition name can be found in 3 h described in chapter 4 3 3 2 1 Possible Compile Error To keep the device list short not all possible device and their types are defined If you get a compile error like Device Type not defined then go to the source code of 3 h search for this line check in the FM3 documentation which device type your device is and put this type manually to the definition Example of occurrence if L3 DEVICE MB9AF10X L3 ON if L3 PACKAGE L3 DEVICE PACKAGE
115. E Stop PPG2 pe FALSE Preserve PPG2 operation state a TRUE Stop PPG4 i 83 FALSE Preserve PPG4 operation state Return Values Description Ok Dedicated PPGs stopped ErrorInvalidParameter e pstcMft NULL e pstcMfsInternData NULL Instance could not be resolved Intance number of internal data out of range corrupted 5 21 14 Mft_PpgSetValue8 Set new 8 bit PPG values of an MFT instance Use this function only if PPG is set to 8 Bit mode Prototype en resule iE cS cus Vai ee MESS cem fs e m ose times E u8PpgNumber uint8 t u8LowValue uint8 t u8HighValue Parameter Name Description in pstcMft Pointer to MFT instance in u8PpgNumber 0 2 4 means PPG0 2 4 in u8LowValue 8 Bit PPG low pulse value in u8HighValue 8 Bit PPG high pulse value Return Values Description Ok Dedicated PPGs set with new values ErrorlInvalidParameter ose NULL PPG number out of range or wrong 5 21 15 Mft_PpgSetValue16 Set new 8 bit PPG values of an MFT instance Use this function only if PPG is set to 16 Bit mode Fujitsu Semiconductor Europe GmbH 205 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype SMS STEN EPOS ere Vae Sec miem e Seca uint8 t u8PpgNumber Vie e ul6LowValue wimnele je ul6HighValue Parameter Name Description in pstcMft Pointe
116. Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD ERASE2 start erase if NAND FLASH ERROR Nand ReadStatus Nand Reset return NAND FLASH ERROR return NAND FLASH OK static void Nand ReadPage uint32 t u32Block uint32 t u32Page uint8 t pu8Buf uint8 t pu8BufPtr pu8Buf uint32 t u32BlockPage uint32 t u32i volatile uint32 t au32Se 16 u32BlockPage u32Block lt lt 5 u32Page 1 block 32 pages Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD READO send read data Extif Nand SetAddress EXTIF NAND ADDRESS 0 Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage amp OxFF Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage gt gt 8 amp OxFF Possible further address cycles here Extif Nand ClearAle EXTIF NAND ADDRESS Extif Wait 500 for u32i 0 u32i lt 512 uS323 tt read 512 bytes pu8BufPtr u32i Extif Nand ReadData EXTIF NAND ADDRI for u321 0 u323 lt 16 u321 read dummy 16 byte au32Se u32i Extif Nand ReadData EXTIF NAND ADDR Fujitsu Semiconductor Europe GmbH 131 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API uint32 t Nand WritePage uint32 t u32Block uint32 t u32Page uint8 t pu8Buf uint8 t pu8BufPtr pu8Buf uint32 t u32BlockPage uint32 t u32i uint32 t au328e 16
117. FALSE Disabl P2 buffer Preble isables TCCP2 buffering p TRUE Enables interrupt generation if 1 is boolean t E set to TCSA0 ICLR UIE S Te TE TUTO Een FALSE uade SE Disables interrupt generation HR TRUE Enables interrupt generation if 1 is boolean t EE set to TCSA1 ICLR Fable FALSE Disables interrupt generation Ee adn TRUE Enables interrupt generation if 1 is boolean t Bi setto TCSA2 ICLR IM ESE TOU ONC FALSE gt e Enable E Disables interrupt generation pe TRUE Enables interrupt generation if 1 is boolean t scu set to TCSA0 IRQZF MESTE FALSE Enable E Disables interrupt generation ER TRUE Enables interrupt generation if 1 is boolean t jur e set to TCSA1 IROZF Enable FALSE Disables interrupt generation TRUE Enables interrupt generation if 1 is boolean t Pee set to TCSA2 IRQZF neerrupe FALSE 1 3 male SE Disables interrupt generation pe bExternal TROD Enables external clock for FRTO COSO FALSE Uses internal clock for FRTO MCU AN 300412 E V14 188 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Enable jou O ECT SEL TRUE Enables external clock for FRT1 g 2 FALSE Uses internal clock for FRT1 Enable E d na TRUE Enables externa
118. FFERSIZE tcConfig pcRxBuffer cRxBuffer Rx Ring Buffer tcConfig ul6RxBufferSize BUFFERSIZE tcConfig enTxCallbackMode MfsOnTxBufferEmpty tcConfig pfnTxCallback amp Mfs0TxCallback tcConfig ul6RxCallbackBufferFillLevel 1 tcConfig pfnRxCallback amp MfsORxCallback S S S S S S S S S S S S S S S S S Mfs Init stc mfsn t sMFS0 amp stcConfig pstcMfs stc mfsn t amp MFSO Setup pointer to USART instance VU Prine Sering Mfs WriteString pstcMfs char cszString 0 Wait for transmission finished via TX call back function while 0 Main u32CountTxCb Read string with 256 chars max lt RETURN gt as terminator echo input Mfs ReadString pstcMfs char amp au8ReadBuffer 256 r 1 A Print string Mfs WriteString pstcMfs n rReceived String u32CountTxCb 0 Fujitsu Semiconductor Europe GmbH 175 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Mfs WriteString pstcMfs char amp au8ReadBuffer 0 while 0 u32CountTxCb I wait E OE Finoh Mfs Read with dedicated number of characters 9 usZGountLx b 07 Mfs WriteString pstcMfs n rNow send 9 Characters not echoed 0 while 0 u32CountTxCb I wait for Finish u32CountRxCb 0 ul 6ReadCount KE Read 9 characters in buffer blocking Mfs Read pstcMfs char amp au8ReadBuffer amp ul6ReadCount 9
119. FIGURES iticcsicscsccievetsceucestntticrsscestscccncecevesdusescosstsacteccccuaedensucevateseusaienssienscasensocens 262 MCU AN 3004 12 E V14 16 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 1 Introduction 1 Introduction The Low Level Library called LLL L3 or L for FM3 MCUs is a driver collection which covers almost all functions of the internal resources such as timers communication interfaces etc The style of this library is based on the L3 of the Fujitsu s CR4 devices This application note describes the architecture of the FM3 Low Level Library and explains how to use it Fujitsu Semiconductor Europe GmbH 17 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 2 L3 Structure 2 L3 Structure THIS CHAPTER EXPLAINS THE STRUCTURE OF THE LLL 2 1 File System The LLL named L3 from now on consists of the following files in its 3 directory lc Common helper function collection e 13h Common definitions of all resources which are implemented and other settings 13 user h User definitions for L3 drivers e interrupts c ISR calls implementation e jnterrupts h ISR prototypes device dependent e ramcode c Functions which are linked and copied to RAM e ramcode h Corresponding ramcode c header file base types I3 h Global L3 definitions and types e g TRUE FALSE en result t etc resourceabbreviationl C Driver functions
120. FallingEdge stcExintConfig apfnExintCallback 0 amp ExintCallback0 stcExintConfig abEnable 1 TRUE stcExintConfig aenlevel 1 ExIntFallingEdge stcExintConfig apfnExintCallback 1 ExintCallbackl Exint Init amp stcExintConfig 5 14 10 2 NMI The following code excerpt shows how to initialize the NMI Assume the NVIC should be initialized by the init function and the NMI should get a callback function Fujitsu Semiconductor Europe GmbH 123 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API tinclude exint h void NmiCallback void Do something function0 stc exint nmi config t stcExintNmiConfig L3 ZERO STRUCT stcExintNmiConfig stcExintNmiConfig bTouchNVIC TRUE stcExintNmiConfig apfnExintCallback amp NmiCallback Exint Nmi Init amp stcExintNmiConfig Please also see NMI handling when RAMCODE is executed in chapter 5 23 1 MCU AN 300412 E V14 124 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 15 EXTIF External Bus Interface Type Definition Configuration Type SEG ektir area Comrie E Address Operator An chip select area is configured with all its parameter in a structure of the type stc extif area config t This area is then initialized by cal
121. Fujitsu Semiconductor Europe Application Note FM3 FAMILY 32 BIT MICROCONTROLLER MB9A BFXXX LOW LEVEL LIBRARY MANUAL APPLICATION NOTE co FUJITSU FUJITSU Low Level Library Manual Chapter 0 Revision History Revision History Date Issue 2012 10 23 V1 0 MWi 1 Version V1 1 MWi Known restrictions chapter added New WDG and NAND Flash 2012 12 14 functions introduced notes on System Init given USB application notes reference added EMAC and ETHPHY note added V1 2 MWi Peripheral activation caution notes added supported instances 29019 0207 Viable added Work Flash now determined by L3 itself V1 3 MWi Flash Timing module description added Dual Operation and 2013 02 18 ECC Flash now determined by L3 itself All Flash device types now supported Ethernet added to project set up 2013 03 28 V1 4 L3 ZERO STRUCT introduced and explained This document contains 262 pages MCU AN 300412 E V14 2 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Warranty and Disclaimer Warranty and Disclaimer The use of the deliverables e g software application examples target boards evaluation boards starter kits schematics engineering samples of IC s etc is subject to the conditions of Fujitsu Semiconductor Europe GmbH FSEU as set out in i the terms of the License Agreement and or the Sale and Purchase Agreement under which agreements the Product h
122. G configuration instance OCUNC OM tigate COE NE CODE TORE stcMftFrtOcuConfig stcMftWfgConfig stcMftPpgConfig pstcMft NULL ZERO STRUCT stcMftFrtOcuConfig 3 ZERO STRUCT stcMftWfgConfig ZERO STRUCT stcMftPpgConfig FRT outputs to high level for anding with PPG signals tcMftFrtOcuConfig bRtOHighLevel TRUE tcMftFrtOcuConfig bRtlHighLevel TRU tcMftFrtOcuConfig bRt2HighLevel TRU tcMftFrtOcuConfig bRt3HighLevel TRU tcMftFrtOcuConfig bRt4HighLevel TRU tcMftFrtOcuConfig bRt5HighLevel TRU El lt same as RTO se same as RT2 se se ID Im o o D o Di pd pd pd D same as RT4 WFG settings tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tcM enWfgClock01 enWfgClock23 enWfgClock45 enWfgMode01 enWfgMode23 enWfgMode45 enWfgGate01 enWfgGate23 enWfgGate45 enWfgPpgSel01 enWfgPpgSel23 enWfgPpgSel45 enWfgPpgEnable01 tWfgPclkl tWfgPclkl tWfgPclkl tWfgRtPpgMode tWfgRtPpgMode tWfgRtPpgMode tWfgRtlOFlaglO tWfgRtlOFlaglO tWfgRtlOFlaglO tWfgGatePpg0 tWfgGatePpg2 tWfgGatePpg4 tWfgPpgPpg ES ES tcM tcM ES ES ES tcM tcM ES ES tcM ES ES tcM tcM ES ES tcM tcM ES ES EC S S S S S S S S S S S S S S S S S S S S S S S S S CC F d iia f E E d f 15 B
123. G01 Gate PPGO enable en mft wfg psel t 5 191 MftWfgGatePpg2 WFGO1 Gate PPG2 enable MftWfgGatePpg4 WFG01 Gate PPG4 enable EE MftWfgGatePpgO WFG23 Gate PPGO enable en mft wfg psel t 57153 MftWfgGatePpg2 WFG23 Gate PPG2 enable MftWfgGatePpg4 WFG23 Gate PPG4 enable m MftWfgGatePpgO WFG45 Gate PPGO enable en mft wfg psel t ge MftWfgGatePpg2 WFG45 Gate PPG2 enable MftWfgGatePpg4 WFG45 Gate PPG4 enable MftWfgRtlRt RTO1 RT1 RTOO RTO enWfgPpg MftWfgRtlPpg RTO1 RT1 PTOO PPGn SEE Po pugne Enable01 MftWfgPpgRt RTO1 PPGm RTOO RTOO MftWfgPpgPpg RTO1 PPGm RTOO PPGn MftWfgRtiRt RTO3 RT3 RTO2 RT2 enWfgPpg MftWfgRtlPpg RTO3 RT3 PTO2 PPGn en mft wfg pgen t Enable23 MftWfgPpgRt RTO3 PPGm RTO2 RTO2 MftWfgPpgPpg RTO3 PPGm RTO2 PPGn Fujitsu Semiconductor Europe GmbH 191 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API MftWfgRt1Rt0 RTO5 RT5 RTO4 RT4 enWfgPpg MftWfgRtlPpg RTO5 RT5 PTO4 PPGn en m t wfg pgen t pnable23 MftWfgPpgRtO RTO5 PPGm RTO4 RTO4 MftWfgPpgPpg RTO5 PPGm RTO4 PPGn bNon TRUE Sets output of the non overlap to tive high polarity FTRO ne Overlap active high polarity 0 High FALSE Does not set non overlap output Polarity0 bNon TRUE Sets output of the non overlap to tive high polarity FTR1 PODIUM ME
124. I include can h uint8 t u8ReceiveCounter 0 void CanTxCompleteCb uint8 t u8MsgBuf void CanRxReceivedCb uint8 t u8MsgBuf stc can msg t pstcRxMsg u8ReceiveCounter function if Ok Can Init pstcCan amp stcCanConfig Can_SetTransmitMsgBuffer pstcCan 1 pstcMsgId can tx msg func ptr t CanTxCompleteCb Can SetReceiveMsgBuffer pstcCan 2 pstcMsgBufferl u32MsgIdMaskl1 can rx msg func ptr t CanRxReceivedCb Can _SetReceiveMsgBuf fer pstcCan 3 pstcMsgBuffer2 u32MsgIdMask2 can rx msg func ptr t CanRxReceivedCb Can UpdateAndTransmitMsgBuffer pstcCan 1 pstcMsgData CanImmediateTransmit Wait for receive callback Rx ID 00Ah L 1h 71h C 77ABh A EF IM while u8ReceiveCounter 2 ID from settings above if stcMsgBuffer2 stcData au8Data 0 0x42 stcMsgBuffer2 stcData au8Data 1 0x43 stcMsgBuffer2 stcData u8DataLengthCode Code for CAN node reception condition 1 Rx ID 001h L 2h 42h 43h C 03EAh A EF ID from settings above amp amp 1 if stcMsgBuffer2 stcData au8Data 0 0x43 stcMsgBuffer2 stcData u8DataLengthCode Code for CAN node reception condition 2 Rx ID 001h L 1h 43h C 04DBh A EF ID from settings above Unknown message was received MCU AN 300412 E V14 72 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Reso
125. KK brief NMI RAMCODE handler kk Fk ke ke ee kk kk kA A kA AA ifdef ICCARM ramfunc elif CC ARM mrateributen section ramtune N else error Please check compiler and linker settings for RAM code endif void NMI Ramcode Handler void Ramcode bNmiOccurred TRUE Set NMI notification for caller FM3 EXTI gt NMICL Clear NMI Ramcode FlashReadReset Stop all possible started Flash commands NMI Ramcode Handler MCU AN 300412 E V14 228 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API The variable Ramcode bNmiOccurred notifies the Flash ROM routines that during RAM execution an NMI occurred These Flash routines then call the user s NMI callback function The following flow diagrams illustrate the mechanisms The ROM execution NMI and its callback handling is shown below Application NMI ISR Callback interrupts c exint C Interrupted NMI_Handler void ExintNMIrgHandler NameCallbackFunction StcExintNMIInternData pfnNMICallback Return Return Resume Figure 5 4 NMI and Callback Flow Diagram ROM Execution The following flow shows the usual NMI service handling if occurred during RAMCODE execution Application NMI ISR Callback ramcode c ExintNMIrqHandler Flash Function A NameCallbackFunction A Sets NMI vector to RAM table ES B Sets NMI vector
126. L3 Resource Driver API 5 22 2 Qprc init This functions initializes an QPRC instance Depending on sct gpre config t bTouchNVIC TRUE it sets also the NVIC registers Prototype en result DEA SECC OE PStcOpuc SEC Gore comite ce jssieClComicsG Parameter Name Description in pstcQpre QPRC instance pointer in pstcConfig Pointer to QPRC configuration Return Values Description Ok Internal data has been setup ErrorInvalidParameter pstcQprc NULL pstcConfig NULL e pstcQprcInternData NULL Instance could not be resolved e Other invalid settings or enumerator used 5 22 3 Qprc Deinit This functions de initializes an QPRC instance Depending on sct gpre config t bTouchNVIC TRUE it sets also the NVIC registers Prototype SMAS SUN t Qore Imit ewro Goren w7 Gne Gee PSC DC comic Eee omic Parameter Name Description in pstcQpre QPRC instance pointer in pstcConfig Pointer to QPRC configuration Return Values Description Ok QPRC is de initialized ErrorlInvalidParameter e pstcQpre NULL pstcConfig NULL pstcQprcInternData NULL Instance could not be resolved Other invalid settings or enumerator used 5 22 4 Oprc Enable This functions enables QPRC counting Prototype wole Ouze Emalgle MSS CCCP c pre Parameter Name Description Ho SIE C Ope
127. LL O Seerne TRUE ADC1 start at zero detection of FRT2 Zero FALSE No ADC1 start generation signal Detection NE ZOO Z Seerne TRUE ADC2 start at zero detection of FRT2 Poe Zero FALSE No ADC2 start generation signal Detection MftAdcCmpUp ADCO start if FRT at Up Peak Down PeakDown Count ACCP match MftAdcCmpUp ADCO start if FRT at Up count ACCP en mft adc cmp enAdcmp0 match Scotia 1e Count MftAdcCmpPeak ADCO start if FRT is in Peak Down Down Count ACCP match MftAdcCmpUp ADCO start if FRT is Up Count PeakDown2 ACCP and Peak Down ACCPDN See above for ADC1 MftAdcCmpUp ADC2 start if FRT at Up Peak Down PeakDown Count ACCP match MftAdcCmpUp ADC2 start if FRT at Up count ACCP en mft adc cmp enAdcmp2 match count t Count MftAdcCmpPeak ADC2 start if FRT is in Peak Down Down Count ACCP match MftAdcCmpUp ADC2 start if FRT is Up Count PeakDown2 ACCP and Peak Down ACCPDN son ACCPO ACCPDNO buffering disable oolean t Buffer FALSE ACCPO ACCPDNO bufferi b pue S E uffering enable See above for ACCP1 ACCPDN1 a EN on ACCP2 ACCPDN2 buffering disable oolean t Buffer FALSE ACCP2 ACCPDN2 butter b We m E uffering enable BA TRUE ACCPO ACCPDNO buffer transfer on cmp0 boolean t PeakValue peak detection E FALSE ACCPO ACCPDNO buffer transfer on Enable zero detection See above for ACCP1 ACCPDN1 b TRUE ACCP2 ACCPDN buffer transfer on Adcmp2 i boolean t PeakValue peak detection FALSE A
128. Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 14 5 Exint DisableChannel To change the activation state of an External Interrupt during runtime this function can be used to disable an individual channel Exint Init with the correct configuration must be called before Prototype en result t Exint DisableChannel uint8 t u8Channel Parameter Name Description in u8Channel Channel of External Interrupt Return Values Description Ok External Interrupt channel successfully disabled ErrorInvalidParameter A not activated channel was tried to be disabled 5 14 6 Exint Nmi Init This function sets the NMI according the configuration structure of the type of stc exint nmi config t Note The NMI shares the interrupt vector with the Hardware Watchog To avoid cross influence of initialization of the NVIC use stc exint nmi config t bTouchNVIC to determine whether to touch the corresponding NVIC registers or not Prototype sm resule E Nimi Mile Swe exclme mii CONTIG E es EE Gone Parameter Name Description cimo scconttg Pointer to NMI configuration structure Return Values Description Ok NMI successfully initialized ErrorInvalidParameter pstcConfig NULL 5 14 7 Exint Nmi Delnit This function disables the NMI Note The NMI shares the interrupt vector with the Hardware Watchog To avoid cross inf
129. MESO Same code as above Mfs DeInit pstcMfs 5 20 35 3 Synchronous Communication The following code shows an example of SPI master communication Assume the SPI master send a 4 byte command and the next 2 frames are the 2 byte slave response finclude mfs h define BUFFERSIZE 256 char cRxBuffer BUFFERSIZE char cTxBuffer BUFFERSIZE Reception Ring Buffer Transmission Ring Buffer function MES MES configuration instance SUCEMES ECCONE roie sitcConb1g stemmtsnet pstcMfs NULL LSSZEROSSTRUGT SEtCCOnfig char au8RxBuffer 4 char au8TxBuffer 4 Suse onis Suse Sono Sec Ou SECCO NC sketontig SOCOM Ce SACCO Miko sketontig Seetonkiig Sic e OB Big SOCOM HS SECCO ste Gon Elige SECCO C SACCO Mo ste Comte Sie C ore enMode enClockSource u32DataRate enParity enStartStopBit u8CharLength bBitDirection bSyncClockInversion bSyncClockOutputDelay pcTxBuffer ul6TxBufferSize pcRxBuffer ul6RxBufferSize enTxCallbackMode pfnTxCallback MfsSynchronousMaster2 MfsUseInternalBaudRateGenerator MfsEightBits 1000000 if 1 MBit s MfsParityNone MfsNoStartNoStop 0 AMS Dat Site FALSE TRUE cTxBuffer S BUFFERSIZE SY cRxBuffer PI C BUFFERSIZE SYNC MfsOnTxBufferEmpty u16RxCallbackBufferFillLevel pfnRxCallback MESTE d stenm sn 2 FGME SNE Ste mE
130. Main Clock wait time 2 fcik gt 2 0 s PlloWaitExp19 PLL Clock wait time 2 fork gt 128 us ohe em PlloWaitExp110 PLL Clock wait time 2 fcik 256 us McoWaitExPl BLL Clock wait time 2 fc1k 26 4 ms uint8 t u8PLIK Ne PLL K value uint8 t u8PllM O soa Mas PLL M value uint8 t u8P11N O sao Mes PLL N value e do PllSrcClkMo PLL clock from Main oscillator A a Ge PllSrcClkHc PLL clock from HC RC oscillator TRUE Interrupt after PLL stabilization wait time boolean t bPllIrg FALSE No interrupt TRUE Interrupt after sub clock stab wait time boolean t bScolrq FALSE No interrupt TRUE Interrupt after main clock stab wait time boolean t bMcolrq FALSE No interrupt EUME DEE E pfnPllStabCb Pointer to PLL stabilization callback MCU AN 300412 E V14 74 Fujitsu Semiconductor Europe GmbH Low Level Library Manual J Chapter 5 L3 Resource Driver API FU ITSU function fuss per t Wessel eis Pointer to sub clock stabilization callback did function func ptr t pfnMcoStabCb S Pointer to main clock stabilization callback function Hook call for low power modes called between SLEEPDEEP 1 and WFI fune EE pfnHook 1 See peripheral manual for exact possible wait time values See peripheral manual and data sheet for exact possible PLL K M N values 3 Check whether the device supports HS RC clock source for PLL PINC bit of PSW TMR 5 5 2 CIk GetParameters This function s
131. OFFSET unsigned char 0 Parameter Name Description in base Base address of used chip select area MCU AN 3004 12 E V14 128 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 15 9 Example Codes 5 15 9 1 SRAM The following code excerpt shows how to use the EXTIF functions for SRAM connected to chips select 1 include extif h define EXTIF ADDRESS 0x61000000 External memory connected to CSX1 function stelose E config t stech E L3 ZERO STRUCT stcExtIF Initialize pins here MDATAO MDATA7 MADOO MAD24 ii MC SI Type 0 device is used so not all configuration is done yet StcExtIF enWidth Extif8Bit StcExtIF bMultplexMode FALSE Not available for Type 0 stcExtIF bReadByteMask FALSE StcExtIF bWriteEnableOff FALSE if L3 NAND SUPPORT L3 ON StcExtIF bNandFlash FALSE Not available for Type 0 fendif stcExtIF bPageAccess FALSE stcExtIF enWriteIdleCycl Extif3Cycle stcExtIF enWriteEnableCycl xtif3Cycle StcExtIF enWriteAddressSetupCycle Ey co StcExtIF enWriteAccessCycl Eats Ey cele StcExtIF enReadIdleCycl xtif3Cycle stcExtIF enFirstReadAddressCycl pote Gyr stcExtIF enReadAddressSetupCycle EEES Gy cele stcExtIF enReadAccessCycl SE stcExtIF enAreaMask ExtiflMB StcExtIF u8AreaAddress uint8 t EXTIF ADDRESS gt gt 20 X
132. OP SCS CEN Parameter Name Description in pstcRtcTime Pointer to RTC time structure Return Value Description Ee E Calculated time or 1 on error 5 25 17 Rtc SetDayOfWeek This function calculates the day of the week from YY MM DD in the Time structure It uses mktime of time h library Prototype sia ese o es Serena Se see Me rte CME Parameter Name Description in out pstcRtcTime Pointer to RTC time structure Return Value Description Ok Day of the week successfully updated in the RTC time structure ErrorlInvalidParameter OSE Che Cu NULL mktime failed 5 25 18 Rtc SetTime This function calculates from the RTC time structure raw time UNIX time It uses localtime ofthe time h library MCU AN 300412 E V14 242 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype sm rzes le Ree fertime Bee cece eue psreRkrernme iile e tRawTime Parameter Name Description out pstcRtcTime Pointer to RTC time structure in tRawTime raw time Return Value Description Ok RTC time structure successfully updated ErrorlInvalidParameter pstcRtc NULL e localtime failed 5 25 19 ReadCallback This function is called if stc rtc config t pfnReadCallback is d
133. Overlap active Ig polar y High FALSE Does not set non overlap output Polarityl bNon TRUE Sets output of the non overlap to pon e Overlap active high polarity FTR2 x High FALSE Does not set non overlap output Polarity2 uintl6 t NE WFG0 1 timer value imerValue uintl6 t pc i gli WFG2 3 timer value imerValue sbajcilo ie A oa WFG4 5 timer value imerValue pfnWfg01 Callback function pointer of WFG 0 1 sane PEE ot Callback interrupt pfnWfg23 S Callback function pointer of WFG 2 3 cunc Callback interrupt pfnwWfg45 RS Callback function pointer of WFG 4 5 PPV Callback interrupt 5 21 1 3 Programmable Pulse Generator Configuration The PPG has the configuration of the type of stc mft ppg config t Type Field Possible Values Description MftPpg8Bit PPGO 8 Bit Mode MftPpg8plus8Bit PPGO 8 8 Bit Mode en mft ppg mode t enPpg0Mode urtppgl6Bit PPGO 16 Bit Mode MftPpgl plusl6Bit PPGO 16 16 Bit Mode PPG2 8 Bit Mode en mft ppg mode t enPpg2Mode see above reci MADE PPG2 16 16 Bit Mode PPG4 8 Bit Mode PPG4 8 8 Bit Mode en mft ppg mode t enPpg4Mode see above PPGA 16 Bit Mode PPG4 16 16 Bit Mode MftPpgPclk2 PPGO Up count clock PCLK 2 MftPpgPclk8 PPGO Up count clock PCLK 8 f lock Ppg0Clock pl nl O MEE a PPG0 Up count clock PCLK 32 MftPpgPclk64 PPGO Up count clock PCLK 64 PPG2 Up count clock PCLK 2 PPG2 Up coun
134. P OM 201 5210 Mft FAREN NE m 201 521 7 MN 202 FEE SES REE 202 TT MINN 202 5 21 10 Mit Giele KE Hee Let E 203 MCU AN 300412 E V14 12 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 5 22 JE Mit ES A EE 204 5 21 12 MIC PTE 204 5 21 13 ME POT NES OP EE 205 5 21 14 M EEE WEE 205 5 21 15 Mit PpaSeValue Tsunade 205 5 21 16 Mft_PpgSetValue8plus8 E 206 5 21 17 M ele le A OR EE 207 5 21 18 Mft_Ppglgbt_Enable EEN 207 5 21 19 Mft_Ppglgbt_Disable es 207 5 21 20 M Ppglobt er 207 5 21 21 FroPeakGallback RET 208 5 21 22 FrinZeroCallDaock aiii aa 208 5 21 23 DOCK estricta dudas 208 5 21 24 WfgxyCallback usina 208 5 21 25 ee Nee EE 208 5 21 26 lcunCallback criada 208 5 21 27 Pron Ca lb iaa ieu isto uti iat dona dU Rad oM A pud utu aite ERR 208 5 21 28 ExvampleCodes sse nennen enne rennen 209 5 21 28 1 Basic FRT Operation with OCU Output 209 5 21 28 2 FRT Operation with OCU Output Dead Time Insertion and PPG Modulation iustus euin nd hk aa 211 521283 PPG only Operation E 214 QPRC Quad Position and Revolution Gountar iet tae ere tuens 217 5 22 1 Configuration Structure PP terre 217 ELE On 220 5223 Q re Ap 220 5 22 4 De END olla 220 5225 OOM Disable lisas paa 220 5225 Qprc_SetPositionCount erica ais epica inde 221 5 22 7 Qprc_SetRevolutionCount esa aa 221 5 22 8 Qprc SetRevolutionCountCompare lt lt lt lt lt
135. PI in case of any error Can_DeInit has to be used if any of the settings from Can Init have to be changed use Can DeInit and afterwards Can Init Can DeInit is used to completely disable the CAN module With Can DeInit all CAN related register values are reset to their default values Also any pending or ongoing transmission or reception will be aborted Each CAN module has CAN MESSAGE BUFFER COUNT number of message buffers which can be used either for reception or transmission of CAN messages Each message buffer for transmission has to be set up first by calling Can SetTransmitMsgBuffer For receiving CAN messages the function Can SetReceiveMsgBuffer has to be used It is possible to set a callback function which will be notified whenever a message has been received Note The numbers of the message buffers used in this driver are indexed from 0 to 31 although the physical addresses of these buffers are indexed from 1 to 32 5 4 1 Configuration Structures 5 4 1 1 CAN overall Configuration The CAN module uses the following configuration structure of the type stc can config t Possible e Type Field Description yp Values can status chg E Callback function for CAN status func ptr t pinstatuetallback changes can be NULL can error func E Callback function for CAN related errors SE pfnErrorCallback can be NULL
136. Pattern 4 MO AS AS 0303456 OSA Erase Sector SAG SAY with wait Flash Erase 0x4000 Flash Erase 0x4004 Program 16 bit word to 0x4000 Flash Writel6 0x4000 0x1234 Write even then odd address lash Write8 0x4004 0x55 lash Write8 0x4005 OxAA ei st even address even of data WriteBlock8 0x4008 au8FlashPat fest even address odd of data lash WriteBlock8 0x4010 au8FlashPat i Test odd address even of data lash WriteBlock8 0x401D au8FlashPat 2 Tesca odd adaress odd k on data Flash WriteBlock8 0x4025 au8FlashE SJ Test of Flash WriteBlock16 Flash WriteBlock16 0x4030 aul6FlashPattern 3 Test Work Flash Area Erase Sector SA0 with wait Flash Erase 0x200C0000 Write even then odd address Flash Write8 0x200C0004 0x55 Flash Write8 0x200C0005 OxAA Fujitsu Semiconductor Europe GmbH 141 MCU AN 300412 E V14 FUJITSU Low Level Library Manual J Chapter 5 L3 Resource Driver API 5 16 7 3 Devices with Dual Operation Flash include flash h function uint8 t au8FlashPattern 8 0 1 2 3 4 5 6 7 uintl6 t aul6FlashPattern 4 MASA AS 023456056 Erase Sector SA8 with wait upper bank Flash Erase 0x4000 Program 16 bit word to 0x4000 Flash Writel6 0x4000 0x1234 jf rice even then odd address lash Write8 0x4004 0x55 lash Write8 0x4005 OxAA Test even add
137. PinChannelEnable Stc wkpin channel t stcWkPinChannelEnable see below Defines Wake up pin active vitm E WkPinChannelLevel 1 i See wkpin channel t stcWkPinChannelLevel see below Defines Wake SPI level PW E bSramRetention TRUE Retain SRAM contents in DSM Enable FALSE No SRAM data retention Hook call for low power modes fume per E pfnHook Called between SLEEPDEEP 1 and WEI instructions 5 11 1 1 Structure of stc hdmi channel t The 8 Bit bitfield structure of stc hdmi channel tis as follows Bitfield Name Size Channel0 1 Channell il reserved 6 5 11 1 2 Structure of stc_wkpin_channel_t The 8 Bit bitfield structure of stc wkpin channel tis as follows Bitfield Name Size ChannelO Channel Channel Channel L1 2 Channels L4 ES Channel reserved 5 11 2 Return cause structure stc dsm return cause t Because it may happen that several return causes occur a 16 Bit bitfield structure for these causes is provided Bitfield Name Size Description InitxReset 1 Return cause INITX Reset LvdReset 1 Return cause LVD Reset LvdInterrupt 1 Return cause LVD Interrupt RtcInterrupt il Return cause RTC Interrupt Hdmi0Interrupt 1 Return cause HDMIO Interrupt HdmilInterrupt 1 Return cause HDMI1 Interrupt l
138. Pointer to MFS instance Return Values Description Ok Purge successfully done ErrorInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved 5 20 12 Mfs BuffersEmpty This Function checks all Buffers software and hardware for an pending Operation Prototype EMMA SUM E 6 his Eurrershj ry Sue mise E enert Parameter Name Description in pstcMfs Pointer to MFS instance Return Values Description Ok Buffers are empty ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved ErrorOperationInProgress Buffers are not empty 5 20 13 Mfs ReadChar Reads a single character from MFS module synchronously or asynchronously The received data is returned top the caller no error checking is done Fujitsu Semiconductor Europe GmbH 163 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API For an asynchronous non blocking call Mfs ReadChar bWait FALSE the function will return immediately after any available character in the internal Rx ring buffer and hardware FIFO if available is found For a synchronous blocking call Mfs ReadChar bWait TRUE the function will return after receipt of a single character The reception interrupt is used in any case Note No error checking is done while reading f
139. RAMCODE L3 ON and address not within Work Flash memory area MCU AN 300412 E V14 136 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 16 4 Flash Block8 This function writes a data block to the Flash memory The data and count is 8 Bit width The return code ErrorInvalidParameter is returned when an input parameter is incorrect or if one data value can not be written because of an invalid o bit to 1 bit transition If u32F1ashAddress is within the Work Flash memory area the corresponding ROM Flash routines are called if Work Flash is available and its area addressed Prototype en result t Flash WriteBlock8 uint32 t u32FlashAddress unte t pusData uint32 t u32DataLength Parameter Name Description in u32FlashAddress Flash address in pu8Data Pointer to 8 Bit data block in u32DataLength 8 Bit data block length Return Values Description Ok Flash programming was successful ErrorTimeout Automatic programming algorithm timed out ErrorOperationInProgress Flash not ready to be programmed ErrorlInvalidParameter e pu8Data NULL e u32DataLength 0 Flash data cannot be programmed because one or more bits cannot be programmed from 0 to s L3 NO FLASH RAMCODE L3 ON and address not within Work Flash memory area 5 16 5 Flash Block16 This function writes a
140. RUE TRUE Stop PPGs consecutively after some tim Some wait delay here Mft PpgSwStop pstcMft FALSE FALSE TRUE Stop PPG4 Some wait delay here Mft PpgSwStop pstcMft FA E Stop PPG2 Some wait delay here Mft PpgSwStop pstcMft TRU E Stop PPGO MCU AN 300412 E V14 216 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 22 QPRC Quad Position and Revolution Counter Type Definition ste coren t Configuration Type stc aprc config t Address Operator QPRCn Init a QPRC instance with Oprc Init Here the callback function pointers for each interrupt cause can be set in the stc qprc config t configuration The recent position count can be read after Oprc Init at any time by Oprc GetPositionCount The same is valid for the revolution count and Oprc GetRevolutionCount After initialization the QPRC does not count immediately Use Oprc Enable to enable the initialized instance and Oprc Disable to disable it temporarily To change the position and revolution count Oprc SetPositionCount and Qprc SetRevolutionCount can be used Note that these functions temporarily disable the counter function for some CPU cycles Oprc SetRevolutionCountCompare Oprc SetPositionRevolutionCountCompare and Oprc SetMaxPositionCount can set new
141. Read and Mfs SynchronousTransfer in an asynchronous way by setting the bWait parameter to FALSE n this case the stc mfs config t pfnRxCallback must be set to a valid value on MFS initialization The function Mfs Read will block until the amount of received data matches the Mfs_Read u16ReadCount value if used in synchronous way The function Mfs SynchronousTransfer Will only block if it is used in asynchronous way and data should be received The Mfs SynchronousTransfer function will neither block in asynchronous nor in synchronous mode if it is used only for sending data Mfs Transfer pu8RxData set to NULL due to the Mfs Transfer u8TransferSize restriction Mfs Transfer u8TransferSize maximum length is the hardware FIFO length For each transmission function M s Read Mfs Write is only one asynchronous operation possible at a time The VC functionality is done w o interrupts or FIFO usage It uses only the following parameter of the MES configuration stc mfs config t enMode and stc mfs config t u32DataRate After initialization of the MFS to PC master mode a start condition has to be sent via Mfs I2C Start Then depending on the protocol bytes can be sent via Mfs I2C WriteSync If a continued or repeated start condition has to be sent Mfs I2C Continue has to be used Any communication has to be finished by the Stop Condition which is sent out by Mfs I2C Stop with the parameter en mfs i2c datadirection
142. SetMode This function sets the clock mode and performs the transition For individual settings such as USB and CAN low power configuration a hook function is called after setting SLEEPDEEP to 1 and final WFI instruction This function is only called if the function pointer is unequal to NULL Additionally the ports will go into Hi Z state if stc clk config t bPortHiZState is TRUE Prototype Sne SU cM Ste Clk coniig MN OST Eee ono Parameter Name Description lial Sie Consist Clock configuration parameters Return Values Description Ok PLL Clock source set ErrorInvalidParameter pstcConfig NULL orlllegal mode 5 5 15 Clk_EnableSubClock This function easily enables the Sub Clock No configuration is needed For stabilization wait time Clk WaitForSubOscillator has to be called afterwards Prototype en resule t cien le Sub eto ei eO CIE Return Values Description Ok Sub Clock enabled ErrorInvalidMode Sub Clock not enabled e g not existing Fujitsu Semiconductor Europe GmbH 79 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 5 16 CIk DisableSubClock This function easily disables the Sub Clock No configuration is needed Prototype SME SUM ODAS ADS S o SKO Sk male Return Values Description Ok Sub Clock disabled 5
143. T is Callback interrupt ee eee Callback function pointer for 0 5 EUME PEE E Second dint t tal iback second interrup f x E rs Callback function pointer for one UNG PEL IE Second dint t Callback second interrup ooa Pie Callback function pointer for one EUNE Jew E Minute muie ini t Caliback minute interrup a PD ODS Callback function pointer for one TUNE PLL E Hour h inii t Catibssk our interrup 5 25 1 2 Alarm Register Enable Strucutre The structure of the type of stc rtc alarm register t used by the configuration has the following fields Only available for Device Types 6 and 7 Fujitsu Semiconductor Europe GmbH 233 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Field Possible Values Description z 0 RTC alarm year register disabled ag eae noD 1 RTC alarm year register enabled 0 RTC alarm month register disabled x SN ph o 1 RTC alarm month register enabled 0 RTC alarm day register disabled OV 1 RTC alarm day register enabled m 0 RTC alarm hour register disabled GE 1 RTC alarm hour register enabled mue S 0 RTC alarm minute register disabled SECH 1 RTC alarm minute register enabled 5 25 1 3 RTC Interrupts Enable Strucutre The structure of the type of stc rtc interrupts t used by the configuration has the following bit fields
144. T and OCU have to be configured to generate an output signal on the RTOx pins If the WFG s configuration is set to NULL it is automatically initialized to through mode In this case the PPGs can only generate interrupts If the PPG shall modulate the OCU signals the WFG has to to be configured for PPG For only using PPGs the OCU configuration has to be set to disabled OCU channels Therefore in contrast to other resource drivers the MFT has more than one configuration to save configuration memory of not used components of an MFT instance The configurations for the MFT components are te mft frt ocu config t FRT and OCU tc mft wfg config t WFG E Ec mft ppg contig t PPG E id En e st mft ieu config t ICU x T P tc mft adcmp config t ADCMP tc mft nzcl config t NZCL tc mft ppg igbt config t IGBT for Type 7 devices only Mft Init initializes an MFT instance The minimum configuration which is needed is defined by stc mft frt ocu config t In this case the MFT s corresponding OCUs are routed directly to the RTOni pins where n is the number of the MFT instance and i the output pin from 0 to 5 The WFG is set automatically to through mode by Mft Init Mft FrtStart starts the FRT operation together with the OCU s configuration Note that because of different start control bit address locations the maximum three FRTs are not started synchronously This drive
145. TS enReadAddress eae boa Read Address Setup Cycle E j Y SetupCycle Timing en extif cycle t enReadAccessCycle see above Read Address Cycle Timing EEE enAdressLatch bora Address Latch Enable Cycle la Y EnableCycle Be Timing EE enAddressLatch Sod above Address Latch Enable pue Y EnableSetupCycle Setup Cycle Timing D A Bu Jet H D en extif cycle rin E BES see above Address Latch Cycle Timing HOS 3 bMclkDivision TRUE Enable MCLK division iU Enable FALSE Disable MCLK division 0 MCLK divided by 1 1 MCLK divided by 2 anere u8MclkDivision Soo ER 14 MCLK divided by 15 15 MCLK divided by 16 Extif1MB 1 MByte external Area Extif2MB 2 MByte external Area Extif4MB en extif mask t enAreaMask D ENE ole Extif64MB 64 MByte external Area Extif128MB 128 MByte external Area uie ic u8AreaAddress Address Bits 27 20 Only available at devices which support NAND Flash I F auto checked by LLL Only available for Device Type1 MCU AN 300412 E V14 126 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 15 2 Extif InitArea This function initializes an external memory area with the given configuration of type of stc extif area config t Prototype Si result Bye TmitAreal uint 18 u8Area Sie Exts arsa comp onto Parameter Name Description Area chip select number Must be correspond to in u8Area supported area of devic
146. TURE siete ccr ohux Es ic sU UE noo Emp zo exei iu rp Alea ea 18 KEN E 18 AO AAN 18 2 3 Graphical Exvample 0000000 nene nennen AAR AA nenne 19 2 4 Interrupt Flow eee 20 3 USING L3 IN OWN APPLICATION PROJECTS o o ooo eee eee eee eee nenene nene 21 3 1 Use Standard Template as Base sse 21 3 2 Adjust L3 to used FM3 Device D cm 23 3 2 1 Possible Compile Error HH eH 23 3 3 Enable Peripherals esses ener nennen en 23 34 Setting Interrupt Levels corria 23 3 5 Combination of Drivers 23 3 5 1 Example ADC and DMA eee 0000000 ena een 23 4 LS MAIN FILES sisi ets deo oc ad ko cs 24 4 1 File base types Dh 24 4 1 1 Type Definitions ERE E O P PO O T LL 24 412 L3 Return Value Type en result Duane rive 24 42 EEN 24 43 FE S iaa EE EE E A E R 25 4 3 4 L3 ZERO STRUCT en 2f 44A File 3 RE IT TT 28 4 4 1 Device Definition eee vr vn 0000000000000 hn 28 4 4 2 Package Definition E 28 4 4 3 Multiple Instances Resource Activation eee 28 444 Single Instances Resource Activation eeseseeeeeeeeeeseeerrerrrrsssesrrrrrrrenesee 29 4 4 5 Interrupt Level Definition eee eee ee ener 29 4 4 6 Numerical Definitions eee eee nenene nenene nn 29 4 4 6 1 Number of ADC channels sse 29 446 2 ADC FIFO Depth eee nnne 29 MCU AN 300412 E V14 4 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 4 4 6 3 Number of DMA Channels eee 30 4 4 6 4 Number
147. Take care of the arbitrary values because there are not checked for plausibility Prototype void Wdg FeedHwWdg uint8 t u8ClearPatternl lame e CE AE Ace eer Parameter Name Description in u8ClearPatternl Pattern of arbitrary value in u8ClearPattern2 Inverted arbitrary value 5 28 7 Static Inline Functions For speed reasons the watchdog driver also provides feed functions which are defined as static inline in the wdg h file 5 28 7 1 Wdg_QuickFeedSwWgd This function does exactly the same as Wdg_FeedSwWdg instead of being compiled as an inline function Prototype static INLINE void Wdg QuickFeedSwWdg void 5 28 7 2 Wdg QuickFeedWwWgd This function does exactly the same as Wdg FeedWwWdg instead of being compiled as an inline function Prototype static INLINE void Wdg FeedHwWdg uint8 t u8ClearPatternl NOS CEE Ace 20 Parameter Name Description in u8ClearPatternl Pattern of arbitrary value in u8ClearPattern2 Inverted arbitrary value 5 28 8 WdgSwCallback If stc wdg config t bIrgEnable is TRUE stc wdg config t pfnCallback must be a valid pointer to a callback function Callback Function void WdgSwCallback void 5 28 9 WdgHwCallback If stc wdg config t bIrgEnable is TRUE stc wdg config t pfnCallback must be a valid pointer to a callback function Callback Function void WdgHwCallb
148. U AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API If several BTs should be combined by certain BTIOSEL I O modes each BT instance must be activated individually by 13 PERIPHERAL ENABLE BTn with L3 ON in D user h Otherwise malfunction of the BT driver may result 5 3 1 Configuration Structures 5 3 1 1 Base Timer The BT module uses the following configuration structure of the type stc bt config t Type Field Possible Values Description BtPwm Pulse Width Modulation Mode BtPpg Programmable Pulse Gen Mode en bt mode t enMode 2 BERIE Reload Timer Mode BtPwc Pulse Width Counter Mode BtExtClkRisingEdge Ext clock BT triggered by rising edge BtExtClkFallingEdge Ext clock BT triggered by falling edge BtExtClkBothEdges Ext clock BT triggered by both edges BtIntClkDivl Int clock PCLK S BtIntClkDiv4 Int clock PCLK 4 ee S enPrescaler BtIntClkDivi Int clock PCLK 16 P BtIntClkDiv128 Int clock PCLK 128 BtIntClkDiv256 Int clock PCLK 256 BtIntClkDiv512 Int clock PCLK 512 BtIntClkDiv1024 Int clock PCLK 1024 BtIntClkDiv2048 Int clock PCLK 2048 T ES ET RUE Restart by software trig or trig input FALSE No restart possible TRUE PWM PPG output masked to low boolean t bOutputLow ie E
149. U2 OCU3 OCU4 WSO SM quB E Compare Sets the OCU5 compare value Value PHP te OR S i Callback function pointer of FRTO n Ed dn B k detection interrupt Callback uae H EEEE f mos E i Callback function pointer of FRT1 ene per SE k detection interrupt Callback pea B ET EE n RS E KG Callback function pointer of FRT2 Nice ee EE R k detection interrupt Callback pea P IEE TACO f SEN pr Callback function pointer of FRTO Une ee E Zero eur Ti t OST zero detection interrup fama sl A a f EE Callback function pointer of FRT1 me DEE E Zero eur m t Tal beck zero detection interrup AREE A f Eee Callback function pointer of FRT2 une Per C Zero vius SE IR UTD Callback zero detectio errup PUE ee pfnocu0 Callback function pointer of OCUO B Callback interrupt Same for OCU1 OCU2 OCU3 OCU4 Puno pert pfnOcu5 2 Callback function pointer of OCU5 EIS Callback interrupt MCU AN 300412 E V14 Fujitsu Semiconductor Europe GmbH Chapter 5 L3 Resource Driver API Low Level Library Manual FUJITSU 5 21 1 2 Waveform Generator Configuration The WFG has the configuration of the type of stc m t wfg config t Type Field Possible Values Description MftWfgPclkl WFG01 count clock cycle PCLK MftWfgPclk2
150. UT POLLING TRIALS INT defined in mfs h ErrorlInvalidParameter e pstcI2c NULL PENIS IPs NUILL enAccess has wrong enumerator pstcMfsInternData NULL Instance could not be resolved 5 20 19 Mfs DC Stop Generates a stop condition for write and read communication Note This function must only be called if the recent MFS instance was initialized to C mode Otherwise the behavior of this function is undefined Prototype em resule u Mre 12C StOOI volatile Ste miem E postene Sngn SMZ Cadecron Parameter Name Description in pstcI2c Pointer to MFS instance access type in enAccess e I2CRead e I2CWrite Return Values Description Ok Stop condition successfully sent ErrorlInvalidParameter e pstcI2c NULL enAccess has wrong enumerator 5 20 20 Mfs I2C WriteSync This function writes n data to a selected device via IC Note Fujitsu Semiconductor Europe GmbH 169 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API This function must only be called if the recent MFS instance was initialized to I7C mode Otherwise the behavior of this function is undefined Prototype Sne SUM SE Cee volaille sre msn t O Sb CT Cy Lane ess pu8Data ane JE u8DataLength Parameter Name Description in pstcI2c Pointer to MFS instance in pu8Data Pointer to byte data to be sent in u8DataLen
151. Value ike tcConfig bUseDivider FALSE tcConfig enDividerRatio RteDivRatiol tcConfig stcAlarmRegisterEnable AlarmYearEnable tcConfig stcAlarmRegisterEnable AlarmMonthEnable tcConfig stcAlarmRegisterEnable AlarmDayEnable S S S S S S S S S tcConfig stcAlarmRegisterEnable AlarmHourEnable tcConfig stcAlarmRegisterEnable AlarmMinuteEnable tcConfig stcRtcInterruptEnable ReadCompletionIrgEn rer Gom ig Ste ECCon fig tecContig LcConfuag EcContug ste se tcInterruptEnable TimeRewriteErrorIrq Enable AlarmIrgEn Enable TimerIrgEn Enable OneHourIrgEn Enable OneMinuteIrgEn tcConfig stcRtcInterruptEnable OneSecondIrqEn tcConfig stcRtcInterruptEnable HalfSecondIrqEn tcConfig pfnReadCallback amp Rtc ReadCallback tcConfig pfnAlarmCallback 9 tcConfig pfnTimerCallback tcConfig pfnHalfSecondCallback tcConfig pfnOneSecondCallback tcConfig pfnOneMinuteCallback tcConfig pfnOneHourCallback se CC se ECTS ER R R ECR EerRternterrup R R R se EE se se SEMO SR SOS OIA s se EGET GN R R R R R R R R R R R R R R R R R R R R R R R R R R CE Oe II E DEE TUV UO OU OS OO OU OS V tcRtcTime u8Year REC Mere 201 2 p tcRtcTime u8Month Rtc_December tcRtcTime u8Day Sue tcRtcTime u8Second 58 tcRtcTime u8Minute 58 lt 58 because of st
152. a P FALSE PWM PPG output as is J boutput TRUE Output inverted high after reset boolean t Invert FALSE No output inversion TRUE i boolean t bOneShot One shot petatom FALSE Continuous operation TRUE RLT PWC in 32 bit mode E 2 c boolean t Deere FALSE RLT PWC in 16 bit mode BtTriggerDisable Trigger input disabled PWM PPG RLT BtTriggerRisingEdge Trigger by rising edge PWM PPG RLT BtTriggerFallingEdge Trigger by falling edge PWM PPG RLT CONDI BtTriggerBothEdges Trigger by both edges PWM PPG RLT trigger e n BtMeasureHighPulse Measurement of high pulse PWC input t s BtMeasureLowPulse Measurement of low pulse PWC E BtMeasureRisingEdges Measurement between rising edges PWC BtMeasureFallingEdges Measurement between falling edges PWC BtMeasureAllEdges Measurement between all edges PWC nimi ae u32Cycle x 32 Bit RLT reload value or or or uintl6 t Oe eebe PWM RLT cycle ul6LowWidth PPG low width WME JE ul6Duty PWM RLT duty ul6HighWidth PPG high width bUnderflow TRUE PWM PPG RLT underflow IRQ and callback rgEnable FALSE PWM PPG RLT no underflow IRQ and callb boolean t bOverflow TRUE PWC overflow IRQ and callback enable rgEnable FALSE PWC no overflow IRQ and callback bTrigger TRUE PWM PPG RLT trigger IRQ and callback rgEnable FALSE PWM PPG RLT no trigger IRQ and callb boolean t E a bCompletion TRUE PWC completion IRQ and callback enable rgEnable FALSE PWC no completion IRQ and
153. a fujitsu com The software examples related to this application note are mb9bfxxx 13 It can be found on the following Internet page http mcu emea fujitsu com mcu product mcu all software htm O Fujitsu Semiconductor Europe GmbH 261 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 List of Figures List of Figures Figure 2 1 Resource Driver Structure Example ert atenta dete a d 19 Figure 2 2 Interrupt and Callback Flow Diagram rca 20 Figure 3 1 Location far L3 ene 21 Figure 3 2 Example of L3 Directory in Workspaces Note that not all files are listed here Tor page space TEASOMS C nennen 22 Figure 5 1 Example ADC Interrupt Scan Conversion er 38 Figure 5 2 Transmission Ring Buffer Principle eerie rere teintes 155 Figure 5 3 Reception Ring Buffer Principle s oerte pu ni nine Enea ned Eten vde 155 Figure 5 4 NMI and Callback Flow Diagram ROM Execution eee 229 Figure 5 5 NMI and Callback Flow Diagram RAM execution eee 229 Figure 6 1 Interrupt Vector Table of IAR Startup Code lt lt lt 258 Figure 6 2 Interrupt Vector Table of KEIL Startup Code ee 259 Figure 6 3 Interrupt NVIC Enumerators of Device s Header File mb9 ab xyz h 259 MCU AN 300412 E V14 262 Fujitsu Semiconductor Europe GmbH
154. able Type Definition stc module t Configuration Type stc module config t Address Operator MODULEn The description begins with the explanation of the configuration s Type Field Possible Values Description Enuml Enum1 description Enum2 Enum2 description STO enc j SE Enum3 Enum3 description Then a short introduction of the module API functions follows After this each API functions is described in detail and the prototype name the arguments and the return values are explained Prototype type Module Function volatile stc module t pstcModule SEC MO cte Mr o misere tee pstecontig a Parameter Name Description in pstcModule Module instance pointer in pstcConfig Pointer to Module instance configuration Return Values Description Return0 Description of Return0 Returnl Description of Return1 Finally the callback functions are introduced Prototype vondi Ce con sss If a callback needs arguments these arguments are explained Fujitsu Semiconductor Europe GmbH 35 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Each API chapter ends with one or some code examples Note that none of the example shows the GPIO and pin relocation settings This depends on the used device and may have the form like this finclude gpiolpin
155. ack void MCU AN 300412 E V14 256 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 28 10 Example Code This code excerpt shows how to use the WDG functions include wdg h void WdgSwCallback void Wdg FeedSwWdg Only for example Do not use this in your application Do something void WdgHwCallback void Wdg OucikFeedHwWdg 0x55 OxAA Only for example Do not use this in your application Do something function stc_wdg config t stcWdgSwConfig stc_wdg config t stcWdgHwConfig ERO STRUCT stcWdgSwConfig ERO STRUCT stcWdgHwConfig 3 2 372 stcWdgSwConfig u32LoadValue 12345678 stcWdgSwConfig bResetEnable TRUE stcWdgSwConfig bIrqEnable TRUE stcWdgSwConfig pfnCallback amp WdgSwCallback Wdg InitSwWdg amp stcWdgSwConfig stcWdgHwConfig u32LoadValue 0000 stcWdgHwConfig bResetEnable E stcWdgHwConfig bIrqgEnable TRUE stcWdgHwConfig bTouchNVIC TRUE stcWdgHwConfig pfnCallback amp WdgHwCallback Wdg InitHwWdg amp stcWdgHwConfig wait for interrupts Fujitsu Semiconductor Europe GmbH 257 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 6 Restrictions 6 Restrictions THIS CHAPTER DESCRIBES THE KNOWN RESTRICTIONS 6 1 Preface Because the FM3 architecture allows almost infinite possible ap
156. adjusts the EPFR register for pin relocation Additionally a possible analog functionality is switched off in the ADE register Macro SetPinFunc PINNAME n MCU AN 300412 E V14 148 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Assume the waveform generator 01 output relocation 1 is located on port P24 and shared its pin with the analog input AN1D The macro SetPinFune RTOOT 1 97 sets the EPRFO1 RTOO1E to RTO01 1 usage sets PFR2 P4 to 1 and switches off ADE AN1D 5 18 6 Example Code The following code excerpt shows how to use the GPIO macros It sets Port10 to output and Port2F to input with enabled internal pull up resistor Additionally the MFSO pins at relocation 2 are enabled finclude gpiolpin h define ON 1 define OFF 0 function MU E PLOCEO OU Gpiutod pin Ina cOur GPTOUPINBL0Gp1otpin mna OFF 9 1 TAE P2E to pul ed ups input Cprolipin i ins tiny NGPTOLPTNEP2 FK Gpuopunsnicbulstupu ON L put logical e USE ONE TO Gpiolpin Put GPIO1PIN P10 ON Check pin state of P2F TE NORE cpLotpinmcet MGPToPTNB2E0 h 77 Activate MESO TX and RX pins at relocation 21 SetPinFunc SINO 2 SetPinkune SOLO 20 Fujitsu Semiconductor Europe GmbH 149 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 19 LVD Low Voltage Detection
157. agram The user does not need to take care of clearing any interrupt because this is automatically handled in the driver s service routines A so called call back function is called to notify the application about an occurred interrupt if needed The L3 also controls the shared vector interrupts and always executes the actual interrupt service routines Some callback functions need to have arguments e g DMA to notify a certain status via these arguments This is explained in the API section of this manual MCU AN 300412 E V14 20 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 3 Using L3 in own Application Projects 3 Using L3 in own Application Projects HOW TO INCLUDE THE L3 TO OWN PROJECTS 3 1 Use Standard Template as Base The first step is to copy the 3 directory to the desired FM3 type template s source directory The next step is to announce this new directory and all the c modules to the workspace of the used tool chain Therefore a new virtual folder 3 may be created New Project L3 Projects mbabfxxx 13 410 C3 common E 5 mbabf50xn template v18 C3 doxy C3 common example E 5 example C ARM Cj ARM G IAR OG AR 3 source Copy to here IG emac Dl Cj source IG usb_config C usb middleware Figure 3 1 Location for L3 modules For the different parts of the LLL make the following subfolders or subgroups in your preferred IDE e B
158. akUpPinO il Return cause Wake up PinO Interrupt VakUpPinl i Return cause Wake up Pin1 Interrupt lakUpPin2 1 Return cause Wake up Pin2 Interrupt VakUpPin3 i Return cause Wake up Pin3 Interrupt lakUpPin4 il Return cause Wake up Pin4 Interrupt VakUpPin5 1 Return cause Wake up Pin5 Interrupt reserved 4 Fujitsu Semiconductor Europe GmbH 107 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 11 3 Definition for Back up Registers For easy access the following definitions were done for the Back up Registers Backup ister pointen types for 8 7 16 and 32 bit access if BN define define define define define define define define define define define define define define define define R01 R02 R03 R04 R05 R06 R07 R08 volatile uint8 t RO9 volatile uint8 ES volatile volatile uint8_ Es volatile uint8_ Es volatile uint8 Es olatile 0x40035906U1 volatile uint8_ tx 0x10035907 0x40035900U1 volatile uint8 KE 03100353908 0x40035901 0x40035902 0x40035903 0x40035904 0x40035905 3 C C C C C R10 R11 R12 R13 R14 R15 R16 olatile 0x40035909U1 olatile 0x4003590A volatile uint8_ t 0x4003590B volatile uint8_ t 0x4003590C volatile 0x4003590DUI volatile uint8 t 0x4003590E volatile uint8 t
159. aligned access type in enAccess e I2CRead I2CWrite Return Values Description Ok Start condition successfully sent ErrorTimeout Arbitration lost No acknowledge e Bus error Transmission finished timed out by 2C TIME OUT POLLING TRIALS INT defined in mfs h Too much trials by 2C TIME OUT POLLING TRIALS defined in mfs h ErrorlInvalidParameter pstcMfs NULL peData NULL pstcMfsInternData NULL Instance could not be resolved 5 20 18 Mfs I2C Continue Generates a continued repeated start condition after a normal start condition is already created Note This function must only be called if the recent MFS instance was initialized to C mode Otherwise the behavior of this function is undefined MCU AN 300412 E V14 168 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype em result t Wiss TAC Comesmbe volatile Ste miem ws pstcr2c ane E u8DestAddress en mfs 12c datadirection t enAccess Parameter Name Description in pstcI2c Pointer to MFS instance in u8DestAddress Address of external IC device 7 Bits bit 0 aligned access type in enAccess e I2CRead I2CWrite Return Values Description Ok Stop condition successfully sent ole e Arbitration lost No acknowledge Bus error Transmission finished timed out by 2C TIME O
160. anonos 45 5 2 16 3 DMA Mode 12 Bif eee eernn 46 Fujitsu Semiconductor Europe GmbH 5 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents GE EE Un RE ETT 49 5 3 1 Configuration Structures Rc 50 5 3 1 1 FET 50 5 3 1 2 Base Timer I O Selectors AAA 51 JE PEER AE np n e REE AEA EEE E AERE ATA E 51 SA PES P AR mmm 52 5 34 dz oom 52 5 3 5 Bt_Disable REE EE Er 52 0 BL leo EE 53 GE E dE d 060 Mee Am 53 5 ENN e WEE 53 530 Bt ruis 53 5 3 10 BE TNG ARSS iia 54 A eee 54 5 312 Bt_CheckPwcError o EE 54 5 3 13 BE Read BUTANO ec 55 5314 Bt BeadDalaButfer33 iii dd 55 A E 55 E XIEEe lrs quim 56 5 317 MAAC ERE A 56 5 39 18 Example Code iii 56 5 3 18 1 BT in PWM MOG6 ases ada etes inet hr Eege 56 5 3 18 2 BT in RLT 32 Bit MOD a 57 5 3 18 3 BT in PPG Mode with simultaneous start of two PPGS 58 5 3 18 4 BT in PWC TE 60 5 4 CAN Controller Area Network AANEREN 62 e ME ee ENEE ef 62 5 4 1 1 GAN overall Configuration cuina 62 54 2 SG EE ER O EEEE EE ARES 63 54 3 GN 64 5 4 4 Can SetTransmitMsgBuffer accionaria tn 64 5 4 5 Can UpdateAnd TransmtMsobufter 65 5 46 Can SetReceiveMsgBuffer etaient tei inicia 66 5 4 7 Can_ResetMsgBuffer oooomcocinnnnccccnnnncccccconononcconnnnncnnonnannncnnnrancncnanannnes 67 54 8 GanTXCallbacK E 68 5 4 9 ele AE EE 68 5 4 10 CanStatusCallback DR 68 5 4 11 CanErrorCallback MT
161. as been delivered ii the technical descriptions and iii all accompanying written materials Please note that the deliverables are intended for and must only be used for reference in an evaluation laboratory environment The software deliverables are provided on an as is basis without charge and are subject to alterations It is the user s obligation to fully test the software in its environment and to ensure proper functionality qualification and compliance with component specifications Regarding hardware deliverables FSEU warrants that they will be free from defects in material and workmanship under use and service as specified in the accompanying written materials for a duration of 1 year from the date of receipt by the customer Should a hardware deliverable turn out to be defect FSEU s entire liability and the customer s exclusive remedy shall be at FSEU s sole discretion either return of the purchase price and the license fee or replacement of the hardware deliverable or parts thereof if the deliverable is returned to FSEU in original packing and without further defects resulting from the customer s use or the transport However this warranty is excluded if the defect has resulted from an accident not attributable to FSEU or abuse or misapplication attributable to the customer or any other third party not relating to FSEU or to unauthorised decompiling and or reverse engineering and or disassembling FSEU does not warrant that t
162. ated CAN unit L3 PREIPHERAL ENABLE CANn pstcMsgData NULL e u8MsgBuf out of range ErrorUninitialized Can SetTransmitMsgBuffer was not called before ErrorOperationInProgress A transmission is pending either wait or call Can ResetMsgBuffer 5 4 6 Can_SetReceiveMsgBuffer Configures and enables a message buffer for reception The acceptance filter is set by pstcMsgBuffer gt stcIdentifier and u32MsgIdMask Each 0 bit in u32MsgIdMask masks the corresponding bit of the received message ID before comparing it to the configured identifier set by pstcMsgBuffer gt stcIdentifier This allows receiving messages with different identifier Setting all bits of u32MsgIdMask to 1 will only accept messages that match the configured identifier If extended identifier is used the u32MsgIdMask will also be interpreted as extended mask identifier If 11 bit identifier is used than u32MsgIdMask will be used as 11 bit mask identifier The application must provide a message buffer object pst cMsgBuffer to be filled with received data After reception of a message that passed the acceptance filter the message s identifier data and data length is copied into the provided message buffer and its bNew flag is set to TRUE The message buffer has to be kept valid until this message buffer is reset Can ResetMsgBuffer A mask identifier has to be set when calling Can SetRecei
163. bDisableAutomatic TRUE Automatic retransmission is disabled oolean t S E Retransmission FALSE Automatic retransmission is enabled sue can bitrate eteBitrate Ce 11 86954144 5 4 1 1 1 Bitrate Configuration The Bitrate configuration has the structure type stc can bitrate t as below 3 Possible Geng Type Field Values Description Range CAN BITRATE TSEG1 MIN to CAN BITRATE TSEG2 MAX bisbal 16 u8TimeSegment1l MCU AN 300412 E V14 62 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API see define section in can h Range CAN BITRATE TSEG2 MIN to aiaee e u8TimeSegment2 CAN BITRATE TSEG2 MAX see define section in can h Range CAN BITRATE SYNC JUMP WIDTH MIN i d 7 TES u8SyncJumpWidth to CAN BITRATE SYNC JUMP a WIDTH MAX 8 D s see define section in can h Range PRESCALER MIN to CAN BITRATE PRESCALER MAX see define section in can h divider for the peripheral clock CLKP2 Bimel te uloPrescaler CanPreDiv11 CAN prescaler clock no division CanPreDiv12 CAN prescaler clock 1 2 CanPreDivl4 CAN prescaler clock 1 4 CanPreDiv18 CAN prescaler clock 1 8 PS Ee CanPreDiv23 CAN prescaler clock 2 3 t m CanPreDivl3 CAN prescaler clock 1 3 CanPreDivl6 CAN prescaler clock 1 6 CanPreDiv112
164. bH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype SME SUM CEE CADSES ASME SU PS VON CHAOS sue ECO SECR C SES wee Comite T Pare Commie Parameter Name Description nfepsterte RTC instance pointer lial pareContig Pointer to RTC configuration structure Return Value Description Ok RTC interrupts successfully en disabled ErrorInvalidParameter pstcRtc NULL e pstcConfig NULL 5 25 8 Rtc EnableDisableAlarmRegisters With this function the Alarm registers can be en or disabled according the configuration Prototype enmnresult m SEHCSEnabilebisabilentaimbegsistesns volatile sicing c ED SI e EO STE Js Conte gg pstcConfig Parameter Name Description Einifesterte RTC instance pointer in pstcConfig Pointer to RTC configuration structure Return Value Description Ok RTC alarm registers successfully en disabled ErrorlInvalidParameter pstcRtc NULL e pstcConfig NULL 5 25 9 Rtc ReadDateTimePolling This function requests a copy of the recent time to the RTC registers and waits until finish The recent time is transfered to the configuration pointer structure Note In this function a possible enabled Read Completion Interrupt INTCRI is temporarily disabled Fujitsu Semiconductor Europe GmbH 239 MCU AN 300412 E V14
165. back to Flash Resume Figure 5 5 NMI and Callback Flow Diagram RAM execution The necessary adjustments in 3 user h are explained in chapter 4 4 7 7 and 4 4 7 8 Fujitsu Semiconductor Europe GmbH 229 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 24 RESET Reset Cause Type Definition Configuration Type Address Operator This driver module does not need any configuration structure but uses a result structure of the type of stc reset result t which has to provided by the caller 5 24 1 Result Structure The following structure is used for retrieving the Reset cause Structure Type sue reser resul e Type Field Description boolean t bPowerOn Power on reset occurred boolean t bInitx INITX external reset occurred boolean t bLowVoltageDetection Low voltage reset occurred boolean t bSoftwareWatchdog Software watchdog reset occurred boolean t bHardwareWatchdog Hardware watchdog reset occurred boolean t bClockSupervisor Clock supervisor reset occurred boolean t bAnomalousFrequency Anomalous frequency detection reset occurred boolean t bSoftware A software reset was issued 5 24 2 Reset GetCause This function returns the reset cause into a given structure of the type of stc reset result t shown above Notes The bitfields of the structure pstcResult must be all 0 before calli
166. bit words for minimum write access to the RTC s date and time registers Note During update global interrupts are temporarily disabled Consinder a possible maximum polling time of 0 5 seconds Prototype Sm resulte E es SED ar une Vvoletile S c MET e CT MATO S t SS C SEG FELG cda 1 EE EE boolean t bPollBusy Parameter Name Description in pstcRtc RTC instance pointer in pstcRtcTime Pointer to time structure TRUE WTCR1 ST 1 polling busy bit in bPollBus on 3 FALSE No polling Return Value Description Ok RTC successfully set with new date and time ErrorlInvalidParameter pstcRtc NULL e Invalid date or time format ErrorTimeout Polling loop timed out ErrorOperationInProgress Update not possible 5 25 6 Rtc SetAlarmDateTime This function updates the RTC alarm time Prototype enam esu te REE S EA Grenda SME volerile Sec Chime OSTERC Sige rre tee tv pstcRtcAlarm Parameter Name Description in pstcRtc RTC instance pointer in pstcRtcAlarm Pointer to alarm structure Return Value Description Ok RTC successfully set with new alarm date and time ErrorInvalidParameter Invalid date or time format 5 25 7 Rtc EnableDisablelnterrupts With this function the interrupts en and disabled by the RTC configuration can be changed MCU AN 300412 E V14 238 Fujitsu Semiconductor Europe Gm
167. bove 77 Init Dual Timer if Set handle IS Ehe ae Set Channel 0 and enable Dt SetChannelConfig pstcDt Dt EnableChannel pstcDt 0 Set Channel 1 and enable Dt SetChannelConfig pstcDt Dt EnableChannel pstcDt 1 Retrigger one shot Dt WriteLoadChannel pstcDt fi Read Channel 1 Ok DETE s tc laca ERD amp stcDtConfigO amp stcDtConfigl amp stcDtConfigl Same as above Same as above Teont igi estet e ong contigo stebDtConfiugis TRUE 0 i Ly Main u32ReadValu Disable Dual Timer Dt DisableChannel pstcDt Dt DisableChannel pstcDt DUtEbeTrnut pstebt RUE In this code example the Dual Timer s mode and thus only needs a single Dt i Dt ReadValueChannel pstcDt amp stcDtConfigl channel 0 was set in chapter 5 12 13 1 to periodic EnableChannel function The other channel was set to one shot mode so it can be retriggered by the function Dr WriteLoadChannel MCU AN 300412 E V14 118 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 13 EMAC ETHPHY Ethernet Macro Ethernet PHY For the Ethernet functionality please refer to Ethernet application notes e AN706 00056 2v0 E Running the free licensed open source TCP IP stack LwIP Lightweight IP including an interactive webserver and a small AJAX example over Ethernet on FM3 e AN706 00059 1V0 E
168. buer i 0 32Block u32Page amp au8Buffer 0 now should contain written data ERROR Nand EraseBlock u32Block ed 32Block u32Page amp au8Buffer 0 now should contain all OxFF erased NAND Flash cells MCU AN 300412 E V14 134 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 16 FLASH Flash Erase and Programming Routines Type Definition Configuration Type Address Operator Flash Erase erases a sector with the given address Flash Write8 and Flash Writel6 program a single byte or 16 bit word to a given Flash address Within the functions it is checked if a Flash bit cell is tried to program from Oo to 1 which is not possible An error is returned in this case and the Flash address is not programmed Flash WriteBlock8 and Flash WriteBlock16 program a block of data with a given length The write functions from above are used Caution If the used device has an ECC Flash the only allowed function calls are Flash Erase Flash WriteEccBlock Notes e f L3 FLASH DMA HALT L3 ON and a Flash routine returns ErrorTimeout the application has to check whether possible DMA transfers are properly resumed again e If L3 NMI RAM VECTOR HANDLE L3 ON the NMI vector is temporarily linked to RAM area during RAMCODE execution If stcExintNMIInternData p
169. buffer has been successfully initialized pstcConfig NULL e pstcCanInternData NULL Invalid or deactivated CAN unit L3 PREIPHERAL ENABLE CANn pstcMsgId NULL e u8MsgBuf out of range ErrorOperationInProgress A transmission is pending either wait or call Can ResetMsgBuffer 5 4 5 Can UpdateAndTransmitMsgBuffer Transmits the message immediately immediate transmission mode or on reception of a matching remote frame remote transmission mode Function Can SetTransmitMsgBuffer must be called before setup the identifier and enable this message buffer Fujitsu Semiconductor Europe GmbH 65 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype en result t Can UpdateAndTransmitMsgBuffer volatile stc cann t pstcCan uint8 t u8MsgBuf const stc can msg data t pstcMsgData en can tx mode t enTxMode Parameter Name Description in pstcCan CAN instance pointer in u8MsgBuf Message buffer index 0 CAN MESSAGE BUFFER COUNT 1 in pstcMsgData Pointer to CAN message data in enTxMode e CanImmediateTransmit e CanRemoteTransmit Return Values Description Ok Message buffer has been successfully updated ErrorInvalidParameter pstcConfig NULL e pstcCanInternData NULL Invalid or deactiv
170. cDtConfigO0 ERO STRUCT stcDtConfigl 352 i32 Configure Dual Timer Channel stcDtConfig0 enMode DtPeriodic stcDtConfig0 enPrescalerDiv DtPrescalerDiv256 stcDtConfig0 enCounterSiz DtConterSize32 stcDtConfig0 bEnable FALSE stcDtConfig0 u32DtLoad 0xF2345670 just stcDtConfig0 u32DtBakgroundLoad 0xFA4567890 just stcDtConfig0 pfnCallback Dt0Callback0 Configure Dual Timer Channel stcDtConfigl enMode DtOneShot stcDtConfigl enPrescalerDiv DtPrescalerDiv256 stcDtConfigl enCounterSiz DtConterSize32 stcDtConfigl bEnable FALSE stcDtConfigl u32DtLoad OxES 667780 use stcDtConfigl u32DtBakgroundLoad Ox E1228 SE stcDtConfigl p nCallback Dt0Callback1 7 7 DT ISS It is recommended for a certain start time not to enable a channel from beginning so let bEnable FALSE in the configuration This configuration is independent from Dt EnableChannel orDt DisableChannel Fujitsu Semiconductor Europe GmbH 117 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 12 13 2 Initialization Parameter Change and De Initialization uint32 t Main u32ReadValue void Dt0Callback0 void void Dt0Callbackl void function Stecmdtnmtopstet stc dt channel Ste dt channel NULL 3 ZERO STRUCT stcDtConfig0 3 ZERO STRUCT stcDtConfigl Same code as a
171. cRtcAlarm u8AlarmMinute stcRtcTime u8Minute 1 tcRtcTime u8Hour 29 tc SetDayOfWeek amp stcRtcTime Set Day of the week in stcRtcTime Fujitsu Semiconductor Europe GmbH 245 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API RawTime Rtc GetRawTime amp stcRtcTime tc SetTime amp stcRtcTime tRawTime tcRtcAlarm u8AlarmYear 0 tcRtcAlarm u8AlarmMonth 0 tcRtcAlarm u8AlarmDay Rod tcRtcAlarm u8AlarmMinute 0 tcRtcAlarm u8AlarmHour BO ET A ET NET e sz Ole ERE Jena TOU EON eee eng amp stcRtcConfig amp stcRtcTime amp stcRtcAlarm TRUE PSESRUGC SS See CC RIEGO wait some time REG Request Daterime pSecRte 2 v Let the callback function do jf che BOSE 5 25 26 2 RTC Timer The RTC Timer can be used as shown in the following code example MCU AN 3004 12 E V14 246 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include url Ch stc cto combo it Ee recommended to be global Ste eel estos le SE CEC E z recommended to be global SEC eka Arm st CRE e recommended to be global uint8 t u8TimerRun void Rtc TimerCallback void u8TimerRun 0 function SE CHA ECM MEN DIC teas te CM SE OTEC time t tRawTime SUCHE EN E pstcRtc Initialization of RTC like in the previous example here
172. ce Driver API FUJITSU tane mde esc function Scc cont Gu se ce onis L3 ZERO STRUCT stcClkConfig if Ok Clk GetParameters amp stcClkConfig Now all recent clock parameters are stored in stcClkConfig The parameters can be changed Assume a transition to HS RC SE clock run mode stcClkConfig enSource CAL sisi ies stcClkConfig bEnableMainClock FALSE Clk SetSource amp stcClkConfig Fujitsu Semiconductor Europe GmbH 85 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 6 CRC Cyclic Redundancy Check Type Definition Stene Configuration Type ste cro contig Address Operator CRCO Initialize the CRC with Crc Init After this there are to ways to calculate the check result e Providing data by CPU via Crc Push8 Crc Pushl6 OrCrc Push32 Using DMA The result can be read by calling Crc_ReadResult The user has to take care of the endianess which is used 5 6 1 Configuration Structure The CRC module uses the following configuration structure of the type stc crc config t Type Field Possible Values Description E P Crcl6 CCITT CRC16 standard 0 Cres IEEE 802 3 CRC3 Ethernet standard TRUE DMA usage needs DMA driver GE EE FALSE Push functions used o Mrinal xen TRUE CRC result as XOR value
173. ceive and transmit buffer provided by the API to create ring buffers So there are 2 receive and transmit steps for sending and receiving data the ring software buffer and the hardware FIFO All necessary parameter to configure a MES channel can be set with the Mfs Init pstcConfig parameter all other interfaces Mfs Read Mfs Write Mfs Purge and Mfs SynchronousTransfer will only operate with data to be sent or received over the configured MFS channel Fujitsu Semiconductor Europe GmbH 153 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API The API can handle the receive and transmit communication by using the Mfs Read Mfs Write and Mis SynchronousTransfer either in synchronous or asynchronous way There is no need for setting the callback function stc mfs config t pfnTxCallback when using the Mfs Write function in synchronous handling mode by setting the parameter bWait to TRUE Note that in synchronous API mode the function will block until all data is put into the transmit hardware FIFO The stc mfs config t pfnTxCallback must be set to a valid value if the API will use the Mfs Write function in an asynchronous way by setting the parameter bWait to FALSE The same for Mfs Read function and Mfs SynchronousTransfer function since Mfs SynchronousTransfer uses receive interrupt to signal transmission complete The API can use Mfs
174. correction to be set Siem Em pstcCalendar see time h for details WC date time structure WE ED WC one second callback function p nCallback mone FONE jE pointer Fujitsu Semiconductor Europe GmbH 249 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 27 2WC Defintions For calculating the tm year the macro Wc Year is provided in wc h Also the values for the months are defined here kk OT TM TO brief Month name definitions not used in driver to be used by Are user applciation KCKCKCkCkCkCkCkCkckCkck kc KKK k kc k kc k kc k Ck k Ck k KKK KKK KKK ck Ck ck KKK KKK KKK KKK ck k ck k ck k ck KKK KKK define Wc January 0 define Wc Febuary define Wc March define Wc April define Wc May define Wc June define Wc July define Wc August define Wc September define Wc October define Wc November define Wc December juo ES a a S INDIES ck ck ckck ckck kk ck ck KA KAZ A K A A AA ZA ZAZ AXA A KZ A kk A ko A A KA ZAZ A ko A A KA ZA ck ko A AZ A A ZA ck ko A ko Sk A KA ck ko A ko Sk k k k kk brief Year calculation macro for adjusting time h year KCKCKCKCkCkCkCk Ck kCkCk Ck k Ck k Ck kk kk kk kk kCk Ck A Ck Ck kCk Ck Ck Ck kCk Ck kCkCkCkCkCkCk Ck kCkCkCk Ck k Ck Ck k k ck k ck k ck k kck ck kk kk define Wc Year a a 1900 5 27 3 Wc Init This function initializes the WC module and sets up the internal data
175. ction pointer for Please also read the NMI handling during RAMCODE execution in chapter5 23 5 14 2 Exint Init This function sets the External Interrupt according the configuration structure of the type of stc exint config t Prototype SMAS SUK E sita me see escala OM es Pene Parameter Name Description in pstcConfig Pointer to EXINT configuration structure Return Values Description Ok External Interrupts successfully initialized ErrorInvalidParameter pstcConfig NULL Illegal Mode 5 14 3 Exint Delnit This function de initializes all External Interrupts Prototype en result t Exint DeInit void Return Values Description Ok All External Interrupts successfully de initialized 5 14 4 Exint EnableChannel To change the activation state of an External Interrupt during runtime this function can be used to enable an individual channel Exint Init with the correct configuration must be called before Prototype en result t Exint EnableChannel uint8 t u8Channel Parameter Name Description in u8Channel Channel of External Interrupt Return Values Description Ok External Interrupt channel successfully enabled ErrorInvalidParameter A not activated channel was tried to be enabled Fujitsu Semiconductor Europe GmbH 121 MCU AN 300412 E V14 Low
176. cu tFrtOcuConfig enFrtOcu2Connection MftFrtlOcu tFrtOcuConfig enFrtOcu3Connection MftFrtlOcu tFrtOcuConfig enFrtOcu4Connection MftFrt20cu tFrtOcuConfig enFrtOcu5Connection MftFrt20cu Pelea Pelo Srel UpDownCount lt CC Ee CC ES CC ES CC ES CC EE CC EE ES CC CC CC CC ES CC CC CC CC EE URB NO QUSE Ty BA S MD EL z z z z rz bi bi p bi BH Ho Boe z z 7 Zz lt lt Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Fh Eh Fh Fh Fh Fh Fh Fh Fh Fh Fh S S S S S S S S S S S S S S S S S S S S S S S S S S S U settings tFrtOcuConfig bOcu0Enable tFrtOcuConfig bOculEnable tFrtOcuConfig bOcu2Enable tFrtOcuConfig bOcu3Enable tFrtOcuConfig bOcu4Enable tFrtOcuConfig bOcu5Enable tFrtOcuConfig bOccpOBufferEnable tFrtOcuConfig bOccplBufferEnable tFrtOcuConfig bOccp2BufferEnable tFrtOcuConfig bOccp3BufferEnable tFrtOcuConfig bOccp4BufferEnable tFrtOcuConfig bOccp5BufferEnable tFrtOcuConfig bOcsaIopOInterruptEnable tFrtOcuConfig bOcsaloplInterruptEnable tFrtOcuConfig bOcsalop2InterruptEnable tFrtOcuConfig bOcsalop3InterruptEnable tFrtOcuConfig bOcsalop4InterruptEnable tFrtOcuConfig bOcsalop5InterruptEnable tFrtOcuConfig bRtOHighLevel tFrtOcuConfig bRtlHighLevel se se Se Ne se se se Ne Ne ve t OQ CQ CQ CQ Co E Ed Ed Ed p Ed db p Dd b d DH lt ab bi b
177. d ReadData EXTIF NAND ADDRESS verify 1 512 byte if u8Data pu8BufPtr u32i return NAND FLASH ERROR for u321 05 us2a lt 16 032355 verify 16 byte dummy data u8Data Extif Nand ReadData EXTIF NAND ADDR MCU AN 300412 E V14 132 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API if u8Data au32Se u32i return NAND FLASH ERROR return NAND FLASH OK function SCE ECO ME ES CCEE LE uint8 t u8MarkerCode uint8 t u8Id uint8 t au8Buffer 512 uint32 t u32i uint32 t u32Page uint32 t u32Block ERO STRUCT DAT DAT DAT DAT DAT DAT DAT PinFunc M PinFunc PinFunc PinFunc M PinFunc M PinFunc PinFunc PinFunc ZS PE g ggg far r far UG S AR der Cat PinFunc M PinFunc PinFunc PinFunc PinFunc tIF enWid Extif8Bit tIF bMultplexMode SE tIF bReadByteMask SE tIF bWriteEnableOff SE tIF bNandFlash TRUE tIF bPageAccess SE tIF bRdyOn SE tIF enWriteIdleCycl tise o EVel tIF enWriteEnableCycl Ltrs Sy cl tIF enWriteAddressSetupCycle kake yen tIF enWriteAccessCycl tif3Cycl tIF enReadIdleCycl CLIE MON AGH tIF enFirstReadAddressCycl ES Sy al tIF enReadAddressSetupCycle RES OVCA tIF enReadAccessCycl ES Sy el tIF enAddressLatchCycle EE yal tIF u8MclkDivision tIF enAreaMa
178. data block to the Flash memory The data and count is 16 Bit width The return code ErrorInvalidParameter is returned when an input parameter is incorrect or if one data value can not be written because of an invalid o bit to 1 bit transition If u32F1ashAddress is within the Work Flash memory area the corresponding ROM Flash routines are called if Work Flash is available and its area addressed The address u32FlashAddress must be 16 Bit aligned even address Fujitsu Semiconductor Europe GmbH 137 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype en result t Flash WriteBlock8 uint32 t u32FlashAddress ane OM E eet OMA uint32 t u32DataLength Parameter Name Description in u32FlashAddress Flash address in pul Data Pointer to 16 Bit data block in u32DataLength 16 Bit data block length Return Values Description Ok Flash programming was successful ErrorTimeout Automatic programming algorithm timed out ErrorAddressAlignment u32FlashAddress not an even address ErrorOperationInProgress Flash not ready to be programmed ErrorlInvalidParameter e pu8Data NULL e u32DataLength 0 Flash data cannot be programmed because one or more bits cannot be programmed from 0 to GE L3 NO FLASH RAMCODE L3 ON and address not within Work
179. dule holds Flash programming routines which are linked for the RAM area For IAR and KEIL tool chains the needed compiler directives or identifier are defined for the automatically copying during start up phase The directives have the following if else structure ifdef ICCARM ramfunc elif CC ARM eee ee Section amu else terror Please check compiler and linker settings for RAM code fendif Between the 4e1if and else another e1if can be inserted for a different compiler by the user ifdef ICCARM ramfunc elif CC ARM Weaver buce re section namtumcm felif USER COMPILER User RAMCODE attributes else error Please check compiler and linker settings for RAM code endif 4 8 File ramcode h This header files contains the Flash sequence addresses and command definitions and the prototypes of the ramcode c functions MCU AN 3004 12 E V14 34 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 L3 Resource Driver API DETAILED DESCRIPTION OF THE RESOURCE DRIVER API AND EXAMPLE CODE 5 1 Preface The following chapters explain all driver modules in alphabetical order The title shows the module name in brackets and upper case followed by the name written out n m MODULE Module Name Below this a small right aligned table shows the module s definition and configuration type and finally the address operator if applic
180. e in pstcConfig External area configuration Return Values Description Ok External Interrupts successfully initialized ErrorInvalidParameter pstcConfig NULL e Area number exceeds EXTIF MAX AREA Other illegal settings 5 15 3 Extif DelnitArea This function clears an external memory area Prototype SMS SUM ECR CBD SHS UNES te S Parameter Name Description Area chip select number Must be correspond to in u8Area supported area of device Return Values Description Ok External Interrupts successfully initialized ErrorInvalidParameter Area number exceeds EXTIF MAX AREA 5 15 4 Extif Nand SetCommand This pseudo function sets an 8 Bit command cycle to the external bus if configured as NAND Flash bus Definition define Extif Nand SetCommand base cmd volatile unsigned char base EXITIF NAND CMD OFFSET unsigned char cmd Parameter Name Description in base Base address of used chip select area NAND Flash command Refer to NAND Flash data in cmd sheet for details 5 15 5 Extif_Nand_SetAddress This pseudo function sets an 8 Bit address cycle to the external bus if configured as NAND Flash bus The number of calls to this function depends on the used address bit width of the NAND Flash memory Fujitsu Semiconductor Eu
181. e RR OvrfUndfZ TRUE Over underfl or zero index IRQ enabled Taza FALSE IRQ disabled Interrupt E le en GE TRUE QPRC RC match IRO enabled nu re 5 FALSE IRQ disabled MESTE bEnablePc EE MatchRc TRUE QPRC PC and RC match IRQ enabled Match FALSE IRO disabled BESS ONE E le MEN c TRUE QPRC PC match IRQ enabled P E FALSE IRO disabled MESTE PE bEnable one Count TRUE Count inversion IRQ enabled Inversion FALSE IRO disabled IDM ESIeIE LH ONE if M NEM 7 P net Pointer to count inversion interrupt TUNE jee Inversion bee RICH Callback fnZ m F A Pointer to zero inted interrupt callback uo PETE c Index mnn Callback une fume i KG Pointer to overflow interrupt callback fune ipeni Overflow f nen Callback eden fume S SE Pointer to underflow interrupt callback Um ET Underflow fined Callback uncon CARES k 7 GER Pointer to RC match interrupt callback fune ipeni Matens function Callback cu NE 5 Fer Pointer to PC match interrupt callback fun eger Mal cs hon Callback uncio fnPcMatch d fune ptr EEN S ps Pointer to PC match and RC match callback interrupt callback function SE e Re Pointer to outrange interrupt callback EUME CT Outrange sedem Callback TRUE Init NVIC registers 1 bT hNVIC i Po ien FALSE Don t touch NVIC registers Fujitsu Semiconductor Europe GmbH 219 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5
182. e Sue deen t p Si CA Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok Priority scan conversion FIFO purged ErrorInvalidParameter pstcAdc NULL 5 2 11 Adc GetStatus This function returns the status of an ADC instance Note that the return type is en adc status t Prototype am ede rerus 1c ACE ECocSiceicus volatile sue acen us psech Parameter Name Description in pstcAdc ADC instance pointer Return Values Description AdcErrorUnknownState pstcAdc NULL or unknown state should never happen AdcStandby Standby for A D conversion AdcPrioInProgress Priority A D conversion priority level 1 or 2 is in progress AdcPrioInProgress Priority A D conversion priority level 1 or 2 is in progress ScanPending Scan conversion is pending AdcPriolInProgress Priority A D conversion priority level 1 is in progress Prio2Pending Priority conversion priority level 2 is pending AdcPriolInProgress Priority A D conversion priority level 1 is in progress Scan Prio2ScanPending conversion and priority conversion priority level 2 are pending 5 2 12 CallbackAdc This function is called if stc adc config t pfnCallbackAdc is defined and the according interrupt is enabled Callback Function VON CMA eT viens 5 2 13 ErrorCallbackAdc This function is called if stc adc conf
183. e clock before For safety reasons this function can be called anyhow with a small timeout count 10 Prototype en result t Clk WaitForClockSourceReady en clk source t enSource bhimes2 18 u32MaxTimeOut Parameter Name Description in enSource Clock Source to be checked in u32MaxTimeOut Time out counter start value Return Values Description Ok PLL Clock stabilized ErrorTimeout Clock Source not ready within time out count ErrorInvalidParameter Not a valid Clock Mode to be checked 5 5 9 CIk MainOscillatorReady This function checks the availability of a stable Main Clock Prototype en result t Clk MainOscillatorReady void Return Values Description Ok Main Clock stabilized ErrorNotReady Main Clock not stabilized yet Fujitsu Semiconductor Europe GmbH 77 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 5 10 CIk SubOscillatorReady This function checks the availability of a stable Sub Clock Prototype emn resule v Clk suboseillarcorksack EIC EC Return Values Description Ok Sub Clock stabilized ErrorNotReady Sub Clock not stabilized yet 5 5 11 CIk PllOscillatorReady This function checks the availability of a stable PLL Clock Prototype en resule Clk EHI SENG TE ey I Void Return Values Description Ok PLL Clock stabil
184. e see above see above Cmm PO enPpg4 el geee amp Dens see above see above TE o oon TRUE PPGO starts with low level GATE d d FALSE PPGO starts with high level GATE m SET TRUE PPG2 starts with low level GATE d un T FALSE PPG2 starts with high level GATE m s PPG4 starts with low level GATE Z T FALSE PPG4 starts with high level GATE me MftPpgPclk2 PPG Compare clock PCLK 2 en mft ppg un um MftPpgPclk8 PPG Compare clock PCLK 8 clock t er T aries sedes PPG Compare clock PCLK 32 MftPpgPclk64 PPG Compare clock PCLK 64 plnej E EE PPGO compare value ompare uint8 t SM PPG2 compare value ompare uint8 t na F PPG4 compare value ompare f pfnPpgo Pointer to PPGO interrupt callback puppi Callback function 3 pfnPpg2 Pointer to PPG2 interrupt callback PDA pe E Callback function pfnPpg4 Pointer to PPG4 interrupt callback une Per at Callback function available if L3 PPG 1616 MODE AVAILABLE 5 21 1 4 Input Capture Unit Configuration L3 ON The ICU has the configuration of the type of stc mft icu config t Type Field Possible Values Description MftIcuFrtO Connects FRTO to ICUO m ET EO Mee curia dl Connects FRT1 to ICUO po TE o t erg rees Connects FRT2 to ICUO Mite u EME Connects FRTO to external MFT 1 Mime ue eMe Connects FRTO to external MFT 2 See above for ICU1and ICU2 MftIcuFrt Connects FRTO to ICU3 EROS enden MftIcuF
185. efined and the according interrupt is enabled The callback function must provide the following arguments Callback Function void ReadCallback uint8 t u8RcbSecond uint8 t u8RcbMinute uint8 t u8RcbHour uint8 t u8RcbDay uint8 t u8RcbDayOfWeek uint8 t u8Month uint8 t u8Year Parameter Name Description in u8RcbSecond Current RTC second in u8RcbMinute Current RTC minute in u8RcbHour Current RTC hour in u8RcbDay Current RTC day of month in u8RcbDayOfWeek Current RTC day of week in u8Month Current RTC month in u8Year Current RTC year 5 25 20 AlarmCallback This function is called if stc rtc config t pfnAlarmCallback is defined and the according interrupt is enabled Callback Function void AlarmCallback void 5 25 21 TimerCallback This function is called if scc rtc config t pfnTimerCallback is defined and the according interrupt is enabled Callback Function void TimerCallback void Fujitsu Semiconductor Europe GmbH 243 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 25 22 HalfSecondCallback This function is called if stc rtc config t pfnHalfSecondCallback is defined and the according interrupt is enabled Callback Function void HalfSecondCallback void 5 25 23 OneSecondCallback This function is called if
186. el Library Manual Chapter 5 L3 Resource Driver API Prototype Sn result v Mra bhim SetBEreak Sus meso vr petelks Parameter Name Description in pstcMfs Pointer to MFS instance Return Values Description Ok MFS Lin Break set being generated ErrorInvalidParameter pstcMfs gt gt NULL ErrorInvalidMode MFS not in Lin master mode MFS is not ready for generating a Lin break TBI 0 ErrorOperationInProgress 5 20 25 Mrs Lin SetNewBaudDivisorf This Function sets a new calculated baud divisor if the MFS is in LIN Slave mode Note This function should only be called MFSisinitialized to Lin slave mode and After a complete LIN frame was received and before next LIN Break and Shortly after the second ICU interrupt within the LIN Synch Field and before the next start bit of the LIN Header byte Prototype en result t MEs han SetNewBaudDivasor Ste misn t psteMfs pilae 18 u32BaudDivisor Parameter Name Description in pstcMfs Pointer to MFS instance in u32BaudDivisor New calculated bit rate divisor Return Values Description Ok New bit rate was set successfully ErrorInvalidParameter psutoMfs NULL ErrorInvalidMode MFS not in Lin slave mode 5 20 26 Mfs Lin TransferRxBuffer This function transfers n bytes of recent receive buffer to user buffer No
187. er dial Se iiem Go nien 3j can be NULL e Pointer to ADCMP configuration structure This in pstcAdcmpConfig pointer can be NULL We l Pointer to PPG configuration structure This pointer umso Sis ce onis can be NULL Return Values Description Ok MFT de initialization successfully done ErrorInvalidParameter pstcMrr NULL 5 21 4 Mft FrtStart This functions starts given FRTs of an MFT instance Mft init must be called before MCU AN 300412 E V14 200 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype sm wesc Mre Beete Ste meca ic Potet boolean t Stoner mao boolean t Dorani Entit boolean t boat Description Parameter Name in pstcMft Pointer to MFT instance A A TRUE Start FRTO i P FALSE No FRTO operation te re T TRUE Start FRT1 i B FALSE No FRT1 operation PET TRUE Start FRT2 i FALSE No FRT2 operation Return Values Description Ok Dedicated FRTs started ErrorInvalidParameter pstcMft NULL e pstcMfsInternData NULL Instance could not be resolved 5 21 5 M t FrtStop This functions stops given FRTs of an MFT in stance Mft init must be called before Prototype SMS STAN EEK V CE SEO SECCO Sie Ma boolean t Dotar
188. er 5 L3 Resource Driver API Bt TriggerInstances BISSSR BTO BIT BTSSSR BT1 BIT SW trigger while 1 5 3 18 4 BT in PWC 32 Bit Mode The following code excerpt shows how to use a BT instances acting in PWC 32 Bit mode It measures the pulse width produced by another BT in PWM mode The input of BT2 has to be connected physically to BT1 output in this case MCU AN 300412 E V14 60 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include bt h uint32 t u32Count uint8 t u8PwcComplete 0 void Bt2CallbackComplete void completion callback of PWC2 Only reading the data buffer clears the interrupt request Expected value stcBtConfigl ul6Duty 1 0x00008013 u32Count Bt ReadDataBuffer32 stc DEN t amp BT2 u8PwcComplete 1 end notification function ste bt contig cts steBtCont1gd See bERconer EE RO STRUCT stcBtConfigl RO STRUCT stcBtConfig2 p Ia SS 3721 tcBtConfigl enMode BtPwm tcBtConfigl enPrescaler BtIntClkDiv4 tcBtConfigl bRestart FALSE No restart one shot mode tcBtConfigl bOutputLow FALSE tcBtConfigl bOutputInvert FALSE tcBtConfigl bTimer32 FALSE PWM has no 32 bit mode tcBtConfigl bOneShot TRUE tcBtConfigl enExtTriggerMode BtTriggerDisable tcBtConfigl ul6Cycle 0xC000 low pulse start phase tcBtConfigl ul6Duty 0x8012 high pulse to be
189. erEndCount This value can be the end of the buffer or any value between the recent index and the buffer size If no interrupts are used init the ADC first start the conversion via Adc TriggerStart the status can be polled by Adc ConversionStatus The buffer s then have to be filled by Adc StoreData If interrupts or DMA is used init ADC first and start the conversion via Adc TriggerStart the callback function referenced in stc adc config t pfnCallback then indicates the complete filled buffer s Adc PurgeFifo and Adc PurgePrioFifo can be called if an error FIFO overrun occurred All remaining data will get lost in this case Nevertheless the overrun flags are cleared automatically by the ADC interrupt handler before the error callback is used if defined Note The FM3 ADC supports only DMA in scan conversion mode f DMA transfer is selected only full 12 bit conversion mode is supported f DMA transfer is selected only one common buffer can be used for each activated channel HW restriction Recently all 32 bit data including ADC value and channel number are stored in an 32 bit buffer Using priority scan mode interrupts must be enabled and DMA must be disabled The user has to take care that the priority scan buffer is big enough according priority FIFO scan interrupt depth e Type3 devices do not support DMA Thus en adc interruptsdma t AdcDma is not available if Device Type3 is selected
190. errupt voltage in the vivinity of 2 3 Volts B DvdIrgVoltage24 Interrupt voltage in the vivinity of 2 4 Volts B LvdIrqVoltage25 Interrupt voltage in the vivinity of 2 5 Volts B LvdIrqVoltage26 Interrupt voltage in the vivinity of 2 6 Volts B LvdIrqVoltage28 Interrupt voltage in the vivinity of 2 8 Volts A B LvdIrqVoltage30 Interrupt voltage in the vivinity of 3 0 Volts A B LvdIrqVoltage32 Interrupt voltage in the vivinity of 3 2 Volts A B LvdIrqVoltage36 Interrupt voltage in the vivinity of 3 6 Volts A B LvdIrqVoltage37 Interrupt voltage in the vivinity of 3 7 Volts A B LvdIrqVoltage40 Interrupt voltage in the vivinity of 4 0 Volts A B LvdlIrqVoltage41 Interrupt voltage in the vivinity of 4 1 Volts A B DvdIrgVoltage42 Interrupt voltage in the vivinity of 4 2 Volts A B 5 19 1 2 Reset Voltage Enumerators The following enumerators are used for en 1vd res voltage t enResVoltage There are existing 2 configuration types B Device Type 3 7 C Device Type 6 Enumerator Description Configuration Type LvdResVoltagel50 Reset voltage in the vivinity of 1 50 Volts C LvdResVoltagel55 Reset voltage in the vivinity of 1 55 Volts C LvdResVoltagel60 Reset voltage in the vivinity of 1 60 Volts C LvdResVoltagel65 Reset voltage in the vivinity of 1 65 Volts C
191. ertion mode 2 en m s u8Sync U MfsSyncWaitOne 1 wait cycle insertion mode 2 Syne WEEE z Clock ur EE Emo MfsSyncWaitTwo 2 wait cycle insertion mode 2 MfsSyncWaitThree 3 wait cycle insertion mode 2 bSignal TRUE NRZI SE System FALSE NRZ lo IG Calo TRUE Clock delay half cycle SPI mode 2 boolean t ES QUE FALSE No Clock delay mode2 Delay lang Es pcTxBuffer Pointer to user transmission buffer Vales T E SC User transmission buffer size ufferSize MCU AN 300412 E V14 156 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU clio E pcRxBuffer Pointer to user reception buffer 8 ul 6Rx is wineleg 1E P User reception buffer size WIRE Callback Number of Data into Buffer until RX ELG JE 0 X x S ul6RxBufferS e i c QM Buffer ESTAS callback function will be called FillLevel ES MESS vo o i re MfsOnTxBufferEmpty Callb if last data was sent to shifter MfsOnTxFinished Callback if last buffer data was sent out mode t Mode as es ClO ay MOOOC p Pointer to transmission callback Eume ENEE E Callback function mS e EG o PENE Pointer to reception callback function TUNE PEZ E Callback f m i Mc quu pfnErr Pointer to error reception callback CIS TEIG ics Callback function perset PCT t bSubstLFE TRUE LF is sent with CR LF MS DOS forma
192. es Sa ala ete MD 251 EA mndpmntanbdndaeaerbdspamiige 252 5 27 8 Example Code eee eee nenene nn 252 5 28 WDG Software and Hardware Watch Dog cccoooocccinnnccccccccoccccnoccnnancnnnnnnnconnnnnnnos 254 5 28 1 Configuration Structure sitiado cicle 254 5 28 2 WG E e AE 254 5 25 2 WIG FeedswiVdg EE 255 mem MS A 255 5 28 5 Wd Disable WWW lis EE 255 5 28 6 VF 256 5 28 7 Static Inline Functions det EE 256 5 28 7 1 Wdg_QuickFeedSwWgd ibm duk t ni acte tac raa napa dese 256 5 28 7 2 Wdg_QuickFeedWwWgd scort 256 lee io stc 256 5 28 9 MN 256 5 28 10 Example Code eee ee een nenene 257 6 RESTRICTIONS iii 258 Fujitsu Semiconductor Europe GmbH 15 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents n NME iic Mx 258 6 2 Resource Activation ooooooooonnonnnnnccooncconconcnoncnnononononnnnnnnnnnnnnnnnnnnnnonnnnnnnnnnnnnnnnnnnnnnns 258 6 3 Interrupt Handler Enumerator Names ooooooocccconoconcnnccnnncnnnnoncnonnnnnnonononnnnnnnnnnnnononns 258 6 4 Interrupt Tvpes ee RKK rhn i rrna EAE errare rena 259 65 MES and DMA cosida ER bien RE EAE sde 260 O ZR O pede aes O 260 6 7 Alternative Interrupt Vector Tables eee nn nn 260 P Ne D PRAPOR E POE MRK O ccm 260 6 9 HDMI CEC Remote Control Hecepnton eee eene 260 6 10 Supported Peripheral nstances rnrn nenn n nenn nn nrnna nenn n nennen 260 7 ADDITIONAL INFORMATION cccccceeessseeeeeeeeeeeeeeeeseneeeeeeeeeeeeseeeseeeeeeeeeeeeeseesnaeees 261 LIST OF
193. esource Driver API include crtrim h function i uintl6 t ul6TrimmData Crtrim SetTrimmingFromFlash u16TrimmData FM3 FLASH IF gt CRTRMM Crtrim SetTrimming ul6TrimmData Crtrim UpdateFlash ul6TrimmData Needs L3 P F im E FLASH L3 ON MCU AN 300412 E V14 94 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 8 CSV Clock Super Visor Type Definition Configuration Type ste csv contig t Address Operator The function Csv_Init initializes the Main and Sub Clock Supervisor CSV if enabled and the Anomalous Freguency Count Detection Supervisor FCS if enabled The CSV is only able to perform a reset on failure detection Therefore after reset in the initialization part of the application the function Csv ReadStatus should be used to determine a possible CSV failure reset cause The FCS first generates an interrupt on anomalous frequency detection In this case a callback function is called with an argument of the content of the Frequency Detection Counter Register FCSWD CTL If stc csv config bFcsIrqgAutoClear is TRUE the interrupt request is cleared within the ISR If this configuration is not set the user may set stc csv config bFcsIrqEnable to FALSE in the callback function call Csv EnableDisable to disable the interrupt and thus let the FCS force a reset on next FCS failu
194. ets the current elements of the configuration according the clock registers Note This function overwrites any configuration To avoid this a second configuration structure like ConfigRecent may be used Also note This function does not set any hook function pointer If this function is used to get the current clock settings as a base for new settings a possible hook function pointer must be set explicitly after copying the configuration Prototype Sm resulte t Clk amamee s sue Clk mec 8 T Ets Parameter Name Description out pstcConfig Clock configuration parameters Return Values Description Ok Clock configuration has been set into pstcConfig ErrorInvalidParameter pstetont MU ErrorInvalidMode Illegal clock mode has been detected 5 5 3 CIk SetDividers This function sets the clock dividers Note It is strongly recommended to disable any resource of its corresponding bus if the bus division setting is changed Malfunction of the resources may result i e wrong baud rates lost data etc Also note Do not access any of the resource registers if the corresponding resource s bus is disabled An immediate bus fault exception will occur in this case Prototype Sm reste CAS Sme sue clk Comrie vo psretonsug Parameter Name Description in pstcConfig Clock configuration parameters Return Values Description Ok Dividers have been se
195. f de tcMftWfgConfig F f iia f f f g B 15 d iia d PPG settings tWfgConfig tWfgConfig enWfgPpgEnable23 enWfgPpgEnable45 tWfgPpgPpg tWfgPpgPpg tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig tWfgConfig bNonOverl bNonOver bNonOver I ul6Wfg017 ul6Wfg231 ul6Wfg45 bWfgInterruptEnable pfnWfg01Callback p nWfg23Callback pfnWfg45Callback DE SE SE lapHighPolarity0 lapHighPolarityl lapHighPolarity2 imerValue imerValue imerValue PpgConfig PpgConfig PpgConfig enPpg0Mode enPpg2Mode enPpg4Mode tPpg8Bit tPpg8Bit tPpg8Bit tcM tcM W mW o o mou oo nu U W Wu ua lt dE E E ig JE tis E E ig JE E E IE ig E ise la arar er Gr a tar ar der lar fer ar Gu PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig PpgConfig enPpgOClock enPpg2Clock enPpg4Clock PpgOInvertPolarity Ppg2InvertPolarity Ppg4InvertPolarity PpgOInterruptEnable Ppg2InterruptEnable Ppg4InterruptEnable PpgOInterrupt Ppg2Interrupt Ppg4InterruptMode lop ler ler der ler ter toy ler der tPpgPclk8 tPpgPclk8 tPpgPclk8 SE iS iS iS iS iS iS iS iS 71 se se se se se ode ode se se NE I OLSA k M Ie
196. f stc gprc config t pfnPcMatchCallback is defined Callback Function void PcMatchCallback void 5 22 23 PcMatchRcMatchCallback This function is called if stc gprc config t pfnPcMatchRcMatchCallback is defined Callback Function void PcMatchRcMatchCallback void 5 22 24 OutrangeCallback This function is called if stc gprc config t pfnOutrangeCallback is defined Callback Function void OutrangeCallback void 5 22 25 Example Code The following example shows how to use the QPRC driver The Position counter is set to Mode 3 and the Revolution Counter to 2 which means BIN acts as clock input and AIN as MCU AN 300412 E V14 224 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API direction input ZIN is unused It counts the position count as one s digit up and down between 0 and 9 At any underflow the counter is set to 9 and at any overflow to 0 The revolution count is the ten s digit between 0 and 9 Fujitsu Semiconductor Europe GmbH 225 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include qprc h SUCHGPRCM C PstcOpre NUI Globally defined because of callback usage void OverflowCallback void if Oprc SetRevolutionCount pstcOprc Opre GetRevolutionCount pstcOprc 10 0 void Underflow
197. f the system needs a stable sub clock i e for communication Prototype en result t Clk WaitForSubOscillator uint32 t u32MaxTimeOut Parameter Name Description in u32MaxTimeOut Time out counter start value Return Values Description Ok Sub Clock stabilized ErrorTimeout Sub Clock not stabilized after timeout count MCU AN 300412 E V14 76 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 5 7 CIk WaitForPllOscillator This function waits for the PLL Oscillator stabilization via polling L3 WATT LOOP HOOK is called during polling It should be called if the system needs a stable PLL clock i e for communication Prototype en result t Clk WaitForPllOscillator uint32 t u32MaxTimeOut Parameter Name Description in u32MaxTimeOut Time out counter start value Return Values Description Ok PLL Clock stabilized ErrorTimeout PLL Clock not stabilized after timeout count 5 5 8 CIk WaitForClockSourceReady This function waits for a clock source meaning a clock source already available or a clock source transition to be expected to be ready soon or already available L3 WAIT LOOP HOOK is called during polling Note This function is not needed to be called if the user has performed the stabilization wait time for the desired sourc
198. fg23TimerValue tWfgConfig ul6Wfg45TimerValue Hr D EDR OR UY wo Uo uw uU O0 WO wu mo Oo ss hohen ooo eb sb dea Fujitsu Semiconductor Europe GmbH 213 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API tWfgConfig bWfgInterruptEnable tWfgConfig pfnWfg01Callback tWfgConfig pfnWfg23Callback tWfgConfig pfnWfg45Callback Wu u u Fh Fh Fh Fh SS U Q settings PogConfig enPpg0Mode MftPpg8Bit PpgConfig enPpg2Mode MftPpg8Bit PpgConfig enPpg4Mode MftPpg8Bit PpgConfig enPpgOClock MftPpgPclk8 PpgConfig enPpg2Clock MftPpgPclk8 PpgConfig enPpg4Clock MftPpgPclk8 PpgConfig bPpgOInvertPolarity FALSE PpgConfig bPpg2InvertPolarity FALSI PpgConfig bPpg4InvertPolarity FALSI PpgConfig bPpgOInterruptEnable FALSI PpgConfig bPpg2InterruptEnable FALSI b b b b d se se se se se PpgConfig bPpg4InterruptEnable FALSI PpgConfig bPpgOInterruptMode FALSI PpgConfig bPpg2InterruptMode FALSI PpgConfig bPpg4InterruptMode FALSI PpgConfig u8Ppg0Low 0x20 PpgConfig u8PpgOHigh 0568077 PpgConfig u8Ppg2Low 0x30 PpgConfig u8Ppg2High 0x90 PpgConfig u8Ppg4Low 0x40 PpgConfig u8Ppg4High OxA0 PpgConfig enPpgOTrigger MftPpgGateSignal PpgConfig enPpg2Trigger MftPpgGateSignal PpgConfig enPpg4Trigger MftPpgGateSignal PpgConfig bPpgOStartLow FALSE PpgConfig bPpg2StartLow FALSE PpgConfi
199. fnNMICallback NULL the NMI callback is used Therefore also activate L3 PERIPHERAL ENABLE EXINTO 7 in 3 user h Read chapter 5 13 for more details 5 16 1 Flash Erase This function erases a Flash sector If u32FlashAddress is within the Work Flash memory area the corresponding ROM Flash routines are called if Work Flash is available and its area addressed Prototype SME SUPA STE 2Se Guanes Mee Ril arsi dime ssa Parameter Name Description in u32FlashAddress An address within the Flash sector to be erased Return Values Description Ok Flash erase was successful ErrorTimeout Automatic erase algorithm timed out ErrorInvalidParameter If L3 NO FLASH RAMCODE L3 ON and address not within Work Flash memory area 5 16 2 Flash Write8 This function writes a byte to the Flash memory If u32FlashAddress is within the Work Flash memory area the corresponding ROM Flash routines are called if Work Flash is available and its area addressed Fujitsu Semiconductor Europe GmbH 135 MCU AN 300412 E V14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype ene SM e Plash Wertes uines2 U327rlasmholress uint8 t u8Data Parameter Name Description in u32FlashAddress Flash address in u8Data 8 Bit Flash data to be programmed Ret
200. fore receiving the terminator character Fujitsu Semiconductor Europe GmbH 165 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype intl6 t Mfs ReadString SEG ESO E Tornei bri Chear ic pcData Dani te ul6MaxChars char t cTerminator boolean t oBehom Parameter Name Description in pstcMfs Pointer to MFS instance in pcData Pointer to string to be received in ul6MaxChars Maximum number of characters to read in Terminator character automatically set to 0 in in cTerminator string destination SN TRUE Echo the reception LAI eremo P FALSE Do not echo the reception Return Values Description gt 0 Number of read characters 0 Parameter u16MaxChars 0 or no data except terminator received pstcMfs NULL peData NULL pstcMfsInternData NULL Instance could not be resolved 5 20 16 Mfs Asynclnit This function sets up a local configuration for asynchronous communication and fills the necessary contents from its arguments Afterwards Mfs Init is called Therefore the user does not need to setup a configuration MCU AN 300412 E V14 166 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API
201. ftAdcCmp Disables ADCMPO Ad 0 Disable en mft adc cmp t E E MftAdcCmpFrt0 Enables ADCMPO for FRTO MftAdcCmpFrt1 Enables ADCMPO for FRT1 MftAdcCmpFrt2 Enables ADCMPO for FRT2 MftAdcCmp Disables ADCMP1 ene Disable en mft adc cmp t MftAdcCmpFrt0 Enables ADCMP1 for FRTO MftAdcCmpFrt1 Enables ADCMP1 for FRT1 MftAdcCmpFrt2 Enables ADCMP 1 for FRT2 MftAdcCmp Disables ADCMP2 Sandon Disable en mft adc cmp t Pre MftAdcCmpFrt0 Enables ADCMP2 for FRTO MftAdcCmpFrt1 Enables ADCMP2 for FRT1 MftAdcCmpFrt2 Enables ADCMP2 for FRT2 bFrt0Adc0 ka Skansen TRUE ADCO start at zero detection of FRTO Zero FALSE No ADCO start generation signal Detection bFrt0Adcl Mee e STARE TRUE ADC1 start at zero detection of FRTO Zero FALSE No ADC start generation signal Detection bFrt0Adc2 Poe wae SEE TRUE ADC2 start at zero detection of FRTO Zero FALSE No ADC2 start generation signal Detection See above for ADC0 1 2 and FRT1 Fujitsu Semiconductor Europe GmbH 195 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API bFrt2Adc0 Due Sarin TRUE ADCO start at zero detection of FRT2 Zero FALSE No ADCO start generation signal Detection logie LAO
202. g bPpg4StartLow FALSE PpgConfig enPpgCompareCl MEtPpgPelk2 PpgConfig u8Ppg0Compare 0 PpgConfig u8Ppg2Compare 0 PpgConfig u8Ppg4Compare 0 PpgConfig pfnPpgOCallback NU PpgConfig pfnPpg2Callback NU PpgConfig pfnPpg4Callback NU se se Ec esi icr ces lees ME se ct a pd a a Eh zna a a dd he hot oo ahs dan S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S ER LO TL O EL O Sp DO EE LA o RO v ROT DEN TEL Tp OE ELE LEE LIO EEN E O EA p oo oo MEE Inuit Ste meno amp IERCH Er MFT instance amp stcMftFrtOcuConfig ERTSOCU Contrguratton amp stcMftWfgConfig WFG configuration NULL NZCL configuration NULL TEU configuration NULL ADCMP configuration tcMftPpgConfig PPG configuration psiseMf a Sec HME MENOS Setup pointer to MFTO instance Mft ErtStart pstcMft TRUI TRUI TRU Start FRTO Starts ERTI Start ERI lt Di pd pd se 5 21 28 3 PPG only Operation This code shows how to initialize the MFT for PPG only operation and software start trigger MCU AN 300412 E V14 214 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU finclude mft function WEE peseta Sir Cem Bem WEJ stc mft ppg Stem ne stc ERT OCU config WFG configuration PP
203. g0 ErrorCode au32AdcBuffer DMABUFF Tilsterdecontigo r u32CannelSelect AD CH 0 enConversionMode enResolution pu32DmaBufferPointer ul6ChannelBufferCounter ul6ChannelBufferEndCount enUseInterruptsDma pfnCallback pfnErrorCallback u8SamplingTime enSamplingTimeMultiplier u8ComparisonTimeDivider Enable Pause enDmaldrq u8DmaChannel u8BlockCount ul6TransferCount enTransferMode enTransferWdith u32SourceAddress u32DestinationAddress ErrorInterruptEnable EnableBitMask RU FA TRUI AdcModeScanConversion Adc12Bit au32AdcBuffer zuo DMABUFFERSIZE AdcDma amp Adc Callback amp Adc I 9 AdcSamplingTimeMultiplier4 ErrorCallback DMABUFFERSIZE DmaDemandTransfer Dma32Bit uint32 t uint32 t amp FM3 ADCO gt SCFD amp au32AdcBuffer FA FA FA a m bi pm se TRUI FALSE se amp Adc Callback O Fujitsu Semiconductor Europe GmbH 47 MCU AN 300412 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API stcDmaConfig pfnErrorCallback ErrorCallback Dma Init Channel amp stcDmaConfig Dma Enable if Ok Adc Init stc adcn t amp ADCO astcAdcConfig0 pstcAdcO stc aden t amp ADCO Un GERT DMA stcDmaConfig bEnable 1 Dma Set Channel amp stcDmaConfig Start ADC Ade TriggerStart p
204. gee Ee AIN active at rising edge BothEdges AIN active at falling or rising edge jose aba ZIN Counter clear function e IRr EE enZinMode CounterClear zinmode t OprcZinGate ZIN Gate function QprcReset Reset Mask SLIDE enPcReset MaskDisable No mask reset rU Mask Mask2Times PC reset RC U C count masked until 2 PC changes mack E Mask4Times PC reset RC U C count masked until 4 PC changes Mask8Times PC reset RC U C count masked until 8 PC changes TRUE uer Mes b8KValue U Outrange mode from 0 to 0x7FFF FALSE Outrange mode from 0 to OxFFFF u16 Position Count register update if uintl6 t Position OCR PSTP 1 not updated Count DAR SI DOS E Revolution Count register update if Blaine LG te Revolution OCR RCM 2 b00 Count BLS DN uintl6 t dass n Position Counter Compare register value 9 Counters Compare DS Besteet S E CES EE Ihe Position and Revolution Counter Compare 3 register value COWIMES TE Compare MCU AN 3004 12 E V14 218 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 16Maxi m E E eh Maximum position count register er increases revolution if stepped beyond E le a TRUE QPRC outrange interrupt enabled boolean t Outrange es FALSE IRQ disabled MESTE bEnabl
205. gth Number of bytes to be sent Return Values Description Ok All data successfully sent EUST GS Arbitration lost e No acknowledge e Bus error ErrorTimeout Transmission finished timed out by 2C TIME OUT POLLING TRIALS INT defined in mfs h ErrorInvalidParameter pstcI2c NULL 5 20 21 Mfs I2C ReadSync Read data to a selected DC device Note This function must only be called if the recent MFS instance was initialized to C mode Otherwise the behavior of this function is undefined Prototype Sme SUM S2 Cee volerie Sus mesa SMS St OZ Cr Lane Es pu8Data ane Se u8DataLength Parameter Name Description in pstcI2c Pointer to MFS instance in pu8Data Pointer to byte data to be read in u8DataLength Number of bytes to be read Return Values Description Ok All data successfully read Era Arbitration lost No acknowledge e Bus error ErrorTimeout Transmission finished timed out by 2C TIME OUT POLLING TRIALS INT defined in mfs h ErrorInvalidParameter pSEELZE gt ID 5 20 22 Mfs I2C SetNoiseFiler Set lC Auxiliary Noise Filters according configuration of type of stc mfs dnf t MCU AN 300412 E V14 170 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API
206. guration Prototype Sm resule v Ade Imite volatile sue aden DSE AC sue ade mem et wt pstcConfig Parameter Name Description in pstcAdc ADC instance pointer O sie Sonia Pointer to ADC instance configuration Return Values Description Ok Initialization successfully done ErrorInvalidParameter pstcAdc NULL e pstcConfig NULL Other invalid configuration settings 5 2 5 Adc Delnit This function de initializes an ADC instance Prototype en resulte t Ade Delale volatile suce cecen 677 sueno Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok De Initialization successfully done ErrorlInvalidParameter pstcAdc NULL 5 2 6 Adc TriggerStart This function triggers an ADC instance for conversion Prototype em result wu Ace Maie erem Sita volatile ste aden t7 SAI GE Parameter Name Description in pstcAdc ADC instance pointer Return Values Description Ok Trigger done ErrorlInvalidParameter pstcAdc NULL 5 2 7 Adc ConversionStatus This function returns an ADC instance conversion status Fujitsu Semiconductor Europe GmbH 41 MCU AN 300412 E V14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype en resulte
207. h NOR Flash SRAM bus enable TE NOR Flash Page access boolean t bPageAccess m mode FALS Normal bus mode TRUE RDY mode enabled 1 R S now Laem E Schon FALSE No RDY mode bStopDataOut TRUE Stop wr data at 1 idle cycle boolean t se E A AtFirstIdle FALSE Extend wr data to last idle Fujitsu Semiconductor Europe GmbH 125 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API cycle TRUE Invert ALE signal t AleI VOS QM Mn FALSE ALE signal high active oe i EE ieee TRUE die Hi Z during ALC VE Linesoff FALSE RE No Hi Z cycle TRUE No MCSX during ALC cycle t M Er pooltooni EEN FALSE MCSX during ALC cycle TEVE MOEX width with FRADC boolean t bMoexWidthAsFradc PALSE MOEX width with RACC i RADC ExtifOCycle ExtiflCycle Extif2Cycle en extif cycl nWriteldleCycl SE Write Idle Cycle Timing Extifl5Cycle Extifl6Cycle ExtifDisabled en extif cycle t enWriteEnableCycle see above Write Enable Cycle Timing ne enWriteAddress Spee Write Address Setup Cycle K Y SetupCycle Timing en extif cycle t enWriteAccessCycle see above Write Access Cycle Timing Sa Suela eyele nReadIdleCycl see above Read Idle Cycle Timing EE enFirstRead EET First Read Address Cycle i Y AddressCycle Timing en
208. h function Inc MESO pins for relocation DN and UART usage SetPinPFunc SINO I S SEEMS OSE OJ NE A Taie CAND pins for relocation V2 SSE MCRAE NUNT Sila ua AGL 2 0 6 See chapter 5 18 5 for more details Carefully check the resource activation in I3 user h before usage whether your device supports a peripheral and especially a certain instance Although there are definitions for the device name and its package the L3 is not able to check for availability MCU AN 300412 E V14 36 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 2 ADC Analog Digital Converter Module Type Definition sees em ic Configuration Type ste ade contig Address Operator ADCn Each ADC channel max 16 gets an own buffer which has to be set up by the user application These buffers and their states are defined in the ADC configuration stc adc config t The buffer pointers are collected in stc adc config t pu8ChannelBufferPointer if 8 Bit conversion method is used or stc adc config t pul6ChannelBufferPointer if 12 Bit conversion method is used The recent buffer index is stored in stc adc config t ul6ChannelBufferCounter This value has to be initialized to 0 by the user or to be set to any value less than the buffer size The end index has to be stored in stc adc config t ul6ChannelBuff
209. he Mfs Write bWait parameter the function return behavior is different For an asynchronous non blocking call M s Write bWait FALSE the free size of the internal buffer must be sufficient to take all data Mfs Write pcData of length Mfs Write ul6DataLength otherwise the function will return ErrorBufferFull After all data is copied into the internal buffer the function will return immediately The transmission may be pending when the function returns For a synchronous blocking call Mfs Write bWait TRUE the function will wait until all data is transferred to the MFS hardware FIFO The transmission may be pending when the function returns If the referenced MFS does not have a FIFO single data is written MCU AN 300412 E V14 160 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype sm wesc Mre Weles Sue miem je psteMfs consisac haac SEO CD alt ETK te ul6WriteCount boolean t bWait Parameter Name Description in pstcMfs Pointer to MFS instance in pcData Pointer to transmission character data buffer Sr Number of characters data to be written Must be gt 0 TRUE Synchronously wait until transmission is finished in bWait JE E FLASE Put all data to transmission internal ring buffer and return Return Values Description Ok Transmission data successfully sen
210. he deliverables do not infringe any third party intellectual property right IPR In the event that the deliverables infringe a third party IPR it is the sole responsibility of the customer to obtain necessary licenses to continue the usage of the deliverable In the event the software deliverables include the use of open source components the provisions of the governing open source license agreement shall apply with respect to such software deliverables To the maximum extent permitted by applicable law FSEU disclaims all other warranties whether express or implied in particular but not limited to warranties of merchantability and fitness for a particular purpose for which the deliverables are not designated To the maximum extent permitted by applicable law FSEU s liability is restricted to intention and gross negligence FSEU is not liable for consequential damages Should one of the above stipulations be or become invalid and or unenforceable the remaining stipulations shall stay in full effect The contents of this document are subject to change without a prior notice thus contact FSEU about the latest one Fujitsu Semiconductor Europe GmbH 3 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents Contents REVISION HISTORY eL a OKO o S 2 WARRANTY AND DISCLAIMER eh k aj l u a k n k 3 GONTEN TS do ee o k r d dd o o k v oo n 4 1 INTRODUCTION E 17 2 L3STRUC
211. his data from address 0x80 3 Perform a sequential write to the EEPROM with 8 bytes of random data starting from address 0x80 and wait 10ms 4 Read back sequentially these data from EEPROM starting from address 0x80 MCU AN 300412 E V14 178 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include mfs h define BUFFERSIZE 256 define I2C SLAVE ADDRESS 0 BEPROM I2C slave address define EEPROM 24C04 0x50 upper address for EEPROM char cRxBuffer BUFFERSIZE Reception Ring Buffer char cTxBuffer BUFFERSIZE Transmission Ring Buffer Delay function may be replaced by timer void MfsWait volatile uint32 t u32WaitCount while u32WaitCount function SECEMESMC OMG Quist CC OMG MES configuration stemfsnit pstcMfs NULL MFS instance L3 ZERO STRUCT stcConfig char au8RxBuffer 8 char au8TxBuffer 8 uint32 t u32ErrorCode uint8 t u8Counter stcConfig enMode MfsI2cMaster stcConfig enClockSource MfsUseInternalBaudRateGenerator stcConfig u32DataRate 400000 400 KBit s Mfs Init stc mfsn t amp MFS1 amp stcConfig pstcMfs stc mfsn t amp MFS1 Setup pointer to USART instance Step 1 Single data write au8TxBuffer 0 0x80 EEPROM memory address au8TxBuffer 1 Oria EEPROM memory data au8RxBuffer 0
212. i dan 150 5 19 1 1 Interrupt Voltage Enumerators erinnere 150 5 19 1 2 Reset Voltage Enumeralbrs coccion 151 5 19 2 BT 152 GMT NES ONE D uem o eM 152 5 194 LvdCallback ig 152 5 19 5 Example Code sse enne enne een nennen nnne 152 5 20 MFS Multi Function Serial Interface reddent re iia 153 5201 Transmission Ring Buffer Principle erinnere basin retur estantes 155 5 20 2 Reception Ring Buffer Principle lt en 155 5 20 3 Configuration Structures I H R 156 5 20 3 1 Asynchronous synchronous and DC Mode 156 52032 bin Mode 157 5 20 3 3 C Noise Filter Configuraton 158 5 20 4 Mfs_Init 158 5 20 5 ER 0 EEE EE Pr iron des 159 EDS Mis IB3dl ED eee ix EE E 159 5 20 7 MIS VVN EE 160 5 20 8 Me Synghirorocus Trastero us pa App MESE stadia 161 520 9 UNIS 9 M 162 5 20 10 Ee AE NEE 162 320 10 ME PG see 163 5 20 12 Mfs_BuffersEmpty cities ri iia ati 163 520713 MiS Fever 163 5 20 14 Mis e AE 164 220 MIS FESTA LEE 165 5 20 16 Mfs_Asynclnit 166 A A 167 5 20 18 MS 126 COn el EE EEE T 168 INEA AA A 169 5 20 20 Me 26 MESTE e is 169 5 20 21 Mis 126 Readsvno saciar 170 O Fujitsu Semiconductor Europe GmbH 11 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents 5 20 22 Mie 126 SetNoiseF iler ecrit adan reste dan 170 5 20 23 p BT Pi pm eec DE c
213. i pH bi Bo EE EE ANA TU Un A aan hohen shy al de Es zh shy ase shi she ha the EN En zn ea Gem j uN E lt MCU AN 300412 E V14 212 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU a lt tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig LErtOCUuCOmnfuc tFrtOcuConfig tFrtOcuConfig LErtOCuGOomfucg EPEE ocuConfug tFrtOcuConfig tFrtOcuConfig Et ocuConfug LEO CUCOnfuc tFrtOcuConfig bMod4 tFrtOcuConfig bMod5 tFrtOcuConfig ul60cu0CompareValue tFrtOcuConfig ul60culCompareValue tFrtOcuConfig ul60cu2CompareValue tFrtOcuConfig ul60cu3CompareValue tFrtOcuConfig ul60cu4CompareValue tFrtOcuConfig ul60cu5CompareValue bRt2HighLevel bRt3HighLevel bRt4HighLevel bCmod01 bCmod23 bCmod45 bOccpOBuf bOccplBuf bOccp2Buf1 bOccp3Buf1 bOccp4Buf1 bOccp5Buf1 bMod0 pbMod1 bMod2 bMod3 a lt S c Se se se se se se se se se se ee se z Ei p pi Ed Ed pd Ed Bd pl pi op Bl p Dd e E lt 0x0400 0x0500 0x0600 0x0700 0x0800 0x0900 CET CHE CET LEr EXE CET EFE LEE EET CEG CET GET Pi A th kA han Eh EA eA Eh h Es Bi th Ebro bh ha Ei h Eh keh ra hy sh oe ki he Eh Eb zb kh cai sy S S S S S S S S S S S S S S S S S S
214. ie Ig rene 0 boolean t bStartEnrti boolean t Svarene Parameter Name Description in pstcMft Pointer to MFT instance EE TRUE Stops FRTO 6 i FALSE Preserve FRTO operation state mM c TRUE Stops FRT1 d FALSE Preserve FRT1 operation state cu en TRUE Stops FRT2 j FALSE Preserve FRT2 operation state Return Values Description Ok Dedicated FRTs stopped ErrorInvalidParameter pstcMft NULL pstcMfsInternData NULL Instance could not be resolved 5 21 6 Mft_FrtRead Reads out the current count of a FRT channel of an MFT instance Note that 0 is returned if pstMft NULL and u8FrtChannel gt 3 and does not mean the counter value 0 Fujitsu Semiconductor Europe GmbH 201 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype lacio Mie Feckeadl Sus meca 0 STEE wines 16 u8FrtChannel Parameter Name Description in pstcMft Pointer to MFT instance in u8FrtChannel 0 1 2 meaning FRT0 1 2 Return Values Description 0 pstcMft NULL e Wrong ERT channel number wineleg E Recent FRT channel counter value 5 21 7 Mft OcuStartStop Start or Stops OCU operation by configuration The operation of a OCU channel is cotrolled by the FRT OCU configurations Prototype entire sulle Miri O CUSTO It COITU CETT C SEG MBE E OCU COMES E pseemiker IESEL eer
215. ig t pfnErrorCallbackAdc is defined and the according interrupt is enabled Callback Function void ErrorCallbackAdc void Fujitsu Semiconductor Europe GmbH 43 MCU AN 300412 E V14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 2 14 PriorityCallbackAdc This function is called if stc adc config t pfnPriorityCallbackAdc is defined and the according interrupt is enabled Callback Function void PriorityCallbackAdc void 5 2 15 PriorityErrorCallbackAdc This function is called if stc adc config t pfnPrioErrorCallbackAdcis defined and the according interrupt is enabled Callback Function void PriorityErrorCallbackAdc void 5 2 16 Example Code The following code excerpts shows some applications of using the ADC driver 5 2 16 1 Polling Mode 8 Bit The following code shows how to use the ADC in polling mode using 8 Bit conversion MCU AN 300412 E V14 44 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include adc h define BUFFER8SIZE function Sue ad cna pstcAdcO NULL ste adc iconkig t EE EE uint8 t au8AdcBufferChO BUFF uint8 t u8Counter L3 ZERO STRUCT stcAdcConfig0 stcAdcConfig0 u32CannelSelect AD CH 0 zur Enable ANO for ADCO tcAdcConfig0 enConversionMode AdcModeScanConversion tcAdcConfig0 enResolution Adc8Bit
216. iggerDisable tcBtConfig0 u32Cycle 0x00024000 Just a random value tcBtConfig0 bTriggerIrqEnable FALSE tcBtConfigO bUnderflowIrqEnable TRUE tcBtConfig0 pfnCallbackl amp BtOCallbackUf underflow irg callback S S S S S S S S S S S Bt ResetIoSel BEEN ste brn eene ee EH EH Bt Enable stc btn t amp BTO Enable BT instance Bt Trigger stc btn t amp BTO0 Ee erand otare LE while 1 5 3 18 3 BT in PPG Mode with simultaneous start of two PPGs The following code excerpt shows how to use a BT instances acting in PWC 32 Bit mode and started by simultaneous software trigger MCU AN 300412 E V14 58 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include bt h void Bt0CallbackUf void underflow detection PPGO Do something void BtlCallbackUf void underflow detection PPG1 Do something function Si Ca bre Cone guess tebe ont SEC bE contig ti SteBLCon 1gd DRUCWSteBt C onBisg0 RUCT stcBtConfigl tConfig0 enMode BtPpg tConfig0 enPrescaler BtIntClkDiv4 tConfig0 bRestart TRUE tConfig0 bOutputLow FALSI tConfig0 bOutputInvert FALSE tConfig0 bTimer32 FALSE PPG has no 32 bit mode tConfig0 bOneShot FALSE tConfig0 enExtTriggerMode BtTriggerRisingEdge tConfig0 ul6LowWidth 0x0100 Just a random tConfig0 ul6HighWidth 0x0200
217. ime The time base is generated from a regularly triggered variable This variable is triggered from the watch counter ISR The Time struct is stored in the internal data structure Calender This function uses localtime of time h library Prototype en result t We Cartas volerile Stre wen CTS Sto C TW CoD Parameter Name Description in pstcWc WC instance pointer Return Values Description Ok Date and time in internal data updated ErrorlInvalidParameter pstcWc NULL pstcWcInternData NULL Instance could not be resolved 5 27 6 Wc SetTimef This function calculates the time and date based on the UNIX Time The time base is generated from a regularly triggered variable This variable is triggered from the watch counter ISR The Time struct is stored in the global structure stcCalendar This function uses localtime of time h library Fujitsu Semiconductor Europe GmbH 251 MCU AN 3004 12 E V 14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype SMS STE Mea t eet en Sue yen Sec SS CC Mae See Commerce Parameter Name Description in pstcWc WC instance pointer in pstcConfig Pointer to WC configuration Return Values Description Ok Date and time successfully set ErrorlInvalidParameter pstcWc NULL pstcWcInternData NULL Instance could not be resolved 5 2
218. iming SetWorkFlashWait v v 5 17 1 Flashtiming GetFlashBufferStatus This function returns the status of the Flash Accelerator Buffer Note this function is only available for Device Types 2 and 4 Prototype en flashtiming flash buffer status t Flashtiming GetFlashBufferStatus void Return Values Description FlashBufferStopInit Flash Buffer is in stop or initialization status and disabled FlashBufferReady Flash Buffer is allowed to be enabled state is not really meaningful should never happen FlashBufferEnable Flash Buffer is enabled but still initialization status FlashBufferRunning Flash Buffer is enabled and running FlashBufferError Switch Case default will never occur 5 17 2 Flashtiming EnableFlashBuffer This function enables the Flash Accelerator Buffer Note this function is only available for Device Types 2 and 4 Prototype en result t Flashtiming EnableFlashBuffer void Return Values Description Ok Flash Buffer enabled Fujitsu Semiconductor Europe GmbH 143 MCU AN 300412 E V14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 17 3 Flashtiming DisableFlashBuffer This function disables the Flash Accelerator Buffer Note this function is only available for Device Types 2 and 4 Prototype en result t Flashtiming DisableFlashBuffer void Return Values Description Ok Flash Buffer
219. ing this method select the rising edge as a trigger input edge using en bt trigger input t BtTriggerRisingEdge configuration Prototype en result t Be Trigger instances vimmel Uler EE ee Parameter Name Description in Bit pattern of BTSSSR BTn definition in bt h ul6TriggerBtInstance Return Values Description Ok Trigger done Correct IOSEL mode is not checked 5 3 11 Bt ReadTimer16 This function returns the recent 16 Bit timer value TMR Prototype EE EE estere Parameter Name Description in pstcBt BT instance pointer Return Values Description une 6 t Recent 16 Bit timer value TMR 5 3 12 Bt CheckPwcError This function reads the ERR bit of the STC register It assumes that the BT is set to PWC mode Otherwise the return value is regardless This bit indicates that the next measurement has been completed in continuous measurement mode before the measurement result is read from the DTBF register In this case the result of the previous measurement in the DTBF register is replaced by that of the next measurement The measurement is continued regardless of the ERR bit value The ERR bit is cleared by reading the measurement result reading DTBF or by calling Bt ReadDataBufferl6 MCU AN 300412 E V14 54 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API
220. instances software based An I O selector can be de initialized reset to mode 0 by using Bt DeInitIoSel To reset all BT I O selectors Bt ResetIoSel can be used Bt ReadTimerl6 or Bt ReadTimer32 reads out the recent timer count if RLT mode was set Bt ReadDataBufferl6 or Bt ReadDataBuffer32 reads out the result count if PWC mode was set Reading the data buffer is mandatory for the callback function because the interrupt request is only cleared by reading the data buffer not by clearing read only EDIR bit It s recommended to use Bt CheckPwcError before to check counter overrun If 32 bit is set for RLT or PWC mode settings are only done in an even numbered BT instance number The instance number 1 is then not available for individual settings anymore Do not use this upper BT instance because the driver does not check this If 32 bit is set for RLT mode the driver takes care of correct 32 bit reload value setting in Bt Init Note that only even numbered BT instances can be used for 32 bit mode and the number 1 is not available for individual settings anymore Note For speed reasons this module does not provide an instance data look up table The callback pointers are held in individual global variables which are only defined if a BT instances is actually activated O Fujitsu Semiconductor Europe GmbH 49 MC
221. interrupt Note the Dual Timer shares its interrupt vector with the QPRC Therefore use bTouchNVIC parameter in Dt Init and Dt DeInit whether to touch the QPRC NVIC registers or not 5 12 1 Configuration Structure The DT module uses the following channel configuration structure of the type stc dt channel config t Type Field Possible Values Description DtFreeRun Free running Mode en dt mode t enMode DtPeriodic Periodic Mode DtOneShot One shot Mode DtPrescalerDivl Prescaler Divisor 1 en dt prescaler t enPrescalerDiv DtRtescalerDivl6 Prescaler Divisor 16 DtPrescalerDiv256 Prescaler Divisor 256 DtConterSizel6 16 Bit counter size enid counters zet nCounterSiz Diele edu 32 Bit counter size TRUE DT Channel enable bool t bEnabl a unos Bs FALSE DT Channel disable uint32 t u32DtLoad W soo bd HT Ticks of Load Register uint32 t u32DtBakgroundLoad 0 OxFFFFFFFF licks of Background Load Register ohe lo FIG jose E pfnCallback BOUDA Callback Fujitsu Semiconductor Europe GmbH 111 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 12 2 Dt Init This function initializes a Dual Timer instance It has the following format Prototype sm zesule De Imit volatile sue den es psiceDe boolean t bTouchNVIC Parameter Name Description in pstcDt
222. iption in pstcMfs Pointer to MFS instance Return Values Description Ok Purge successfully done ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved 5 20 10 Mfs PurgeTx The hardware transmission FIFO and the software buffer are cleared Any data which is not transferred at this time will be lost All settings done by M s Init will be preserved DMA operation for write will be disabled and write access to transmit buffer by CPU will be enabled MCU AN 300412 E V14 162 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype en restle SEUS EHO ste miten t PSLCMES Parameter Name Description in pstcMfs Pointer to MFS instance Return Values Description Ok Purge successfully done ErrorInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved 5 20 11 Mfs Purge The hardware transmission and reception FIFOs and the software buffers are cleared Any data which is not transferred at this time will be lost All settings done by M s Init will be preserved DMA operation for write and read will be disabled and write access to transmit buffer by CPU will be enabled Prototype sm restlle SEAS C sue mesa 6 PSTelks Parameter Name Description in pstcMfs
223. iption lial pstoconfuig Pointer to CSV configuration structure Return Values Description Ok CSV settings have been updated successfully ErrorInvalidParameter pstcConfig NULL MCU AN 300412 E V14 96 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 8 5 Csv EnableDisableParam This function en or disables the FCS Main CSV and Sub CSV according to the arguments Also the FCS interrupt and its auto clear option can be en or disabled with this function This function can be used instead of Cou EnableDisable ifthe configuration structure is not saved on runtime Csv Init must be called before Prototype en result t Csv EnableDisableParam boolean t bMainCsvEnable boolean t bSubCsvEnable boolean t bFcsEnable boolean t bFcsIrqEnable boolean t bFcsIrqAutoClear Parameter Name Description in bMainCsvEnable TRUE Enable Main CSV FALSE Disable Main CSV in bSubCsvEnable TRUE Enable Sub CSV FALSE Disable Sub CSV in bFcsEnable TRUE Enable FCS FALSE Disable FCS in bFcsIrqgEnable TRUE Enable FCS Interrupt FALSE Disable FCS Interrupt in bFcsIrgAutoClear TRUE Enable FCS Interrupt auto clear in ISR FALSE Disable FCS Interrupt auto clear in ISR Return Values Description Ok CSV settings have been updated successfully 5 8 6 Csv ReadStatus
224. it PUBLIC vector table DATA vector table DCD sfe CSTACK Top of Stack DCD Reset Handler Reset CANO IRQHandler SACAN ESO CAN1 IROHandler Pp Ss ANS Figure 6 1 Interrupt Vector Table of IAR Startup Code MCU AN 300412 E V14 258 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 6 Restrictions In the KEIL environment the adjustment of the example above has to be done at marked lines in the code excerpt below Vector Table Mapped to Address 0 at Reset AREA RESET DATA READONLY H VEGAS l Vectors End lp Vectors Size _ Vectors instal Sp A LOPS Or Stack Reset Handler Reset Handler CANO IROHandler ESAE CAN bart CANT IROHandler SS ON CDS Figure 6 2 Interrupt Vector Table of KEIL Startup Code For other IDE and tool chains than IAR and KEIL adjust the names accordingly The same appears to the interrupt enumerators for the NVIC intrinsic functions which are defined in the device s header file mb9 ab xyz h Example with same situation from above CANn IROn versus ETHERn CANn IROn KKK RK KK KK KKK kk kk kk kk kk kk kk AKA KKK kck kc k KKK KKK kck kck kck kc k KKK KKK kck kc k KKK KKK KKK Interrupt Number Definition KCKCKCKCKCKCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCkCk Ck Ck kCk Ck Ck k Ck k Ck kCkCkCkCkCk k kCkCk Ck kCkCk Ck CkCkCk k Ck kCk ck k ck k ck ck ckckckck typedef enum IROn NMI IROn 14 2 Non
225. ized ErrorNotReady PLL Clock not stabilized yet 5 5 12 Clk SetSource This function sets the clock source and performs transition if wanted Illegal transitions e g changing PLL settings or switch to PLL from other modes than Main Clock are checked and corresponding error values are returned Precondition Clk SetStabilizationWaitTimes has to be called before Prototype Sne S eneen sue Clk Comro ic ee one Parameter Name Description in pstcConfig Clock configuration parameters Return Values Description Ok Clock source set ErrorInvalidParameter pstcConfig NULL ErrorInvalidMode Clock setting not possible MCU AN 300412 E V14 78 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 5 13 CIk_SetPliSource This function sets the PLL input clock source if the device supports HS RC Clock input for PLL This function only works if PLL is disabled Attention The L3 itself does not check the PINC bit availability Prototype Sne SU Soc Ses Elk comrrie ce josiceComerg 3 Parameter Name Description in pstcConfig Clock configuration parameters Return Values Description Ok PLL Clock source set ErrorInvalidParameter pstcConfig NULL orlllegal mode ErrorInvalidMode Clock setting not possible PLL not disabled 5 5 14 Clk
226. k TRUE Enable PLL boolean t bEnablePll FALSE Done stable PL TRUE Enable Main Clock AL E leM lock pe Ber VE Do not enable Main Clock TRUE Enable Sub Clock Je E 3b lock boolean t pes FALSE Do not enable Sub Clock ClkRun Run modes ClkSleep Sleep modes ClkTimer Timer modes ClkStop Stop mode en clk mode t enMode ClkDeepStop Deep standby mode If RTC available on device sue RTC mode ClkDeepRtc Deep standby RTC mode TRUE High z pin state in timer and stop mode pacco Dro ECCLES eS Pins not touched in timer and stop mode ApbODiv1 PCLKO Division 1 1 i ApbODiv2 PCLKO Division 1 2 en clk apbOdiv t enAPBODiv EE PCLKO Division 1 4 ApbODiv8 PCLKO Division 1 8 Apb1Div1 PCLK1 Division 1 1 P i Apb1Div2 PCLK1 Division 1 2 en clk apbldiv t enAPBlDiv Apb1Div4 PCLK1 Division 1 4 Apb1Div8 PCLK1 Division 1 8 Apb2Divl PCLK2 Division 1 1 A Apb2Div2 PCLK2 Division 1 2 en clk apb2div t enAPB2Div Apb2Div4 PCLK2 Division 1 4 Apb2Div8 PCLK2 Division 1 8 TRUE Disables APB1 regardless of settings boolean t bAPBlDisable FALSE APB1 enabled TRUE Disables APB2 regardless of settings boolean t bAPB2Disable FALSE APB2 enabled ScowaitExp10 Sub Clock wait time 2 cu 10 3 ms Solace a ScoWaitExp11 Sub Clock wait time 2 ox gt 720 5 ms ScoWaitExp17 Sub Clock wait time 2 fcik gt 1 31 s McoWaitExp11 Main Clock wait time 2 foi 500 ns EA onou EROS enMCOWaitTime McoWaitExp15 Main Clock wait time 2 fci k gt 8 us McoWaitExp123
227. k k Ck k Ck kk k k ck k ck k ck k ck k ck ck ck ck ckckckck kk if L3 DEVICE MB9AF10X L3 ON if L3 PACKAGE L3 DEVICE PACKAGE N L3 PACKAGE L3 DEVICE PACKAGE R define L3 DEVICE TYPE L3 TYPEO else error Device Type not defined endif Lif L3 DEVICE MB9AF11 E GES PACKAGI L S PACKAGI PACKAGI L ON PACKAGI PACKAGI define L3 DEVICE El felif ES PACKAGE PACKAGI define L3 DEVIC ES else error Device Typ endif s PACKAGI J sit ea ies EE nj Di A Finally the user activated resources are defined for the compilation process Ck ck Ck ck kk kk Ck KA K A A K A A A A Ck ZK AKA A A A ZAZ A K A A K A Ck Ck AK AA KA Ck Ck XK AZ A AZ KA kk kk A KA kA k kc ko k k Ax 3 resourses nable check note It does not check if a device has actually any in 13 h enabled Meo resource and all instances available kk KKK KK KKK KKK KKK KKK KKK k k ck KKK kCk k ck A k Ck Ck k kCk Ck k k Ck k k k Ck k k kc k k ck k ck k ck k ck Ck ck ck KKK KKK Activate code for dma c if L3 PERIPHERAL ENABLE DMA L3 ON fdefine L3 PERIPHERAL DMA ACTIVE endif MCU AN 300412 E V14 26 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 4 L3 Main Files
228. k2 Bellos Belo Mf Mf TRUE TRUE TRU O un apa e ENS s BO e FA FA FA FA FA rz pm bi pH bi BH GB Sl OSE OZ 0x1234 MftFrt00Ocu MftFrt0Ocu Mifite Bust GO cu Mt Bt OC MftFrt20cu MftFrt20cu No Ne Ne Ne Ne Ne Ne Ne Ne e se Ed p p pd pi pr pd pi pi pi pl p n n n n ab bi bi BH BH Hoe MCU AN 300412 E V14 210 Fujitsu Semiconductor Europe GmbH UpDownCount UpDownCount UpDownCount Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig tFrtOcuConfig Blees ert tFrtOcuConfig tFrtOcuConfig LErtOGCUGOmnfucg EPrEOcuContag tFrtOcuConfig tFrtOcuConfig ER tOcucon tela LE EO CUGCOnfuc ct a a ere a eme al Qr Tor or 16 16 lt lt R PA Eh th Estote Eh Eb Es ro shy Eh th Eh Eben Eb Eb Eh ei eA th h e Eh Eh Eh Eh Eh Eh Eh kh Eh eh tFrtOcuConfig tFrtOcuConfig LErtOCUGOnmnfauc Blees ert tFrtOcuConfig tFrtOcuConfig c oOcuCconfig LErtOCUCOmnfuc tFrtOcuConfig tFrtOcuConfig LErtOCUCODEucG tFrtOcuConfig S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S teo cu OE Edge trt O CU On Eg EE conos tFrtOcuConfig EE HE bCmod01 bCmod23 bCmod45 bOccpOBuf7 DOCCPUBUNEJ
229. kCk kCk Ck kCkCk Ck kCkCk Ck kCkCk Ck k k Ck Ck kk ck k ck k ck k kck ck ck kckckck kok define L3 NO FLASH RAMCODE L3 OFF Fujitsu Semiconductor Europe GmbH 31 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 4 L3 Main Files 4 4 7 6 Flash Routines DMA Halt This macro defines whether to halt beside interrupts also possible DMA transfers before calling RAM routines ck ck Ck ck kk kk Ck Ck ck KAZ A KA A AA X AZ ZX AX A A X A ZA AX A A KA Ck Ck AK A KA ZA ZK AZ ck AZ KA kk A ZA A KA KA A Mk ko ko kc ko ko ko kokok brief Global DMA halt during Flash routines kk Possible values are SON DMA is globally halted during Flash routine executions kam TST OER T DMA SSmo touched im Elash routines KKK KKK KKK kCkCk Ck KKK KKK KKK kCk Ck Ck KKK KKK kCkCk kk kk Ck kCk Ck KKK k k ck k ck k ck k KKK KKK define L3 FLASH DMA HALT L3 ON 4 4 7 7 RAMCODE NMI Vector Handle If an NMI occurs during RAM code execution the NMI vector must be temporarily patched to RAM location This switch determines whether to do this or not ck ck ck ck ck ck ck kk ck ck ck kk ck KKK KKK kk ck kk KK KKK KKK KKK k X A KKK AX AA X ck ko kv ko kk kv ko ko ko brief Global NMI service during Flash routines Only used if RAMCODE is SS used and L3 FLASH DMA HALT L3 ON KR not Because the NMI callback of the Ext I F driver module is used pus also To PERDPHERAL ENABLE EXINTO 7 has to be
230. kc ec e ec kc e c ke e ec echec cec ec kc kc c kc kc kc ko de brief Month name definitions not used in driver to be used by Se user applciation KKK KK KKK KKK KKK KR KK KKK Ck k Ck Ck Ck k Ck kk kk KKK kCkCk Ck kk kk kk kk KKK KKK ck k ck k kck ck ck KKK define Rtc January l tc Febuary 2 tc March S Ee Aprii 4 tc May S 6 7 8 define R define R define R define R define Rtc June define Rte July define Rtc August define Rtc September 9 define Rtc October 10 define Rtc November 11 define Rtc December 12 kk EE brief Day of week name definitions not used in driver to be used by A user applciation FEA ee kc k Ck ck ee ee NA define Rtc Sunday 0 define Rtc Monday define Rtc Tuesday define Rtc Wednesday define Rtc Thursday define Rtc Friday define Rtc Saturday MCU AN 300412 E V14 236 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 25 3 Rtc Init This function initializes the RTC module and sets up the internal data structures If the sub clock was not enabled before the sub clock enable and stablilization is done in this function The user has to define the recent time in a structure of the type of stc rtc time t explained in chapter 5 25 1 4 Also a structure of the type of stc rtc alarm t has to be defined see chapter 5 25 1 5 even if the alarm functionality is not used The structure field
231. ko ko brief User Number of DMA channels If a device does not support DMA it is not needed to set this value to O0 kk Number of available DMA channels 1 to 8 FE ee KKK KK k kc k kc kk kk ck Ck k k Ck kCk kk k k KKK kk kk KKK KKK KKK ck k ck k ck k ck k KKK KKK KKK define L3 DMA CHANNELS 8 4 4 6 4 Number of external Interrupts The number of available external interrupts is specified by the following definition XCckckckck kck AKA ck KA KAZ A K A A A A Z A kk AXA A K A kk A KA A KA ZAZ A ko A A KA ZA ck ko A ko A A ZA ck ck ck ko Sk A KA ck Sk A ko kv k k k kk brief User Number of external interrupt channels kk Number of available EXINT channels 1 to 16 A define L3 EXINT CHANNELS 16 Do not specify a number higher than the maximum available external interrupt inputs 4 4 7 Special Activators Some activators and availability of a resource cannot be done by the device and package definition only For these cases some special activators are provided and the use has to set them individually 4 4 7 1 PPG 16 16 Mode Because the 16 16 mode of the PPG is not used often it can be undefined by setting L3 PPG 1616 MODE AVAILABLE to L3 OFF ck ck ckck KK AKA ck KA KAZ AK A A A A Z A kk AXA A KA kk A X A A KA ZAZ A ko A A KA Ck ck ck ko ck ko A A ZA kk ck KA A NA MA A ko Sk k Sk ko kc ko kk brief User 16 16 Bit activation for PPG configurati
232. l block the pin Prototype SMA C SUN C t Dee Tieden Ste dacn es tender n 0 1 Parameter Name Description in pstcDac DAC instance pointer Return Values Description Ok DAC channel enabled Fujitsu Semiconductor Europe GmbH 99 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 9 3 Dac DisableO Dac Disable1 These functions disable a DAC channel Prototype emn result v CD S ADO See lecum SD Ac Parameter Name Description in pstcDac DAC instance pointer Return Values Description Ok DAC channel disabled 5 9 4 Example Code The following code excerpt shows how to use the DAC by output of two sine wave tones MCU AN 300412 E V14 100 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include dac h include lt math h gt define DAC MAX DATA 1024 Number of samples uintl6 t aul6SinusO DAC MAX DATA uintl6 t aul6Sinusl DAC MAX DATA function float64 t f64Sinus float64 t f64Phi float64 t f64Pi 3 141592636 Frequency 0 sample step float64 t f64Fract0 f64Pi float64 t 2 float64 t DAC MAX DAT Frequency 1 sample step float64 t f64Fractl f64Pi float64 t 4 float64 t DAC MAX DAT uintl6 t ul6Index uint32 t u32Delay Create sine wave tones for ul6Inde
233. l clock for FRT2 boolean t C LOI Za ls FALSE Uses internal clock for FRT2 Enable WIG He Oe WilmedS i Se FRTO cycle setting VIS BP Lo uintl6 t Gele FRT1 cycle setting USETE ETNO Se FRT2 cycle setting MftFrt0Ocu Connects FRTO to OCUO HOUR DNE EVO ENTE MftFrt0Ocu Connects FRTO to OCUO connect t a Connection ME Connects FRTO to OCUO MftOcuFrtMftl Connects FRT of external MFT1 MftOcuFrtMftl Connects FRT of external MFT2 Same for OCU1 OCU2 OCU3 OCU4 MftFrt0Ocu Connects FRTO to OCU5 TT KE MftFrt0Ocu Connects FRTO to OCU5 connect t nii omen eee Connects FRTO to OCUS MftOcuFrtMft1 Connects FRT of external MFT1 MftOcuFErtMftT Connects FRT of external MFT2 DOO ME bOcuO TRUE Enables operation of OCUO Enable FALSE Disable operation of OCUO Same for OCU1 OCU2 OCU3 OCU4 EE bocub TRUE Enables operation of OCU5 Enable FALSE Disable operation of OCU5 bo On A me BAe CU TRUE Enables operation of OCUO m E lii FALSE Disable operation of OCUO Enable Same for OCU1 OCU2 OCU3 OCU4 bo Bn x ENE m TRUE Enables operation of OCU5 ps FALSE Disable operation of OCU5 bOcsalop0 TRUE Enables interrupt generation if 1 is boolean t ESE set to OCSA IOPO Enable FALSE Disables interrupt generation Same for IOP1 TOP2 IOP3 IOP4 bOcsalop5 TRUE Enables interrupt generation if 1 is boolean t TMC set to OCSA IOP5 Enable FALSE Disables interrupt generation TRUE i i bRtOHigh Sets RTO to high level only if
234. lback is defined where n is 0 1 or 2 Callback Function void FrtnPeakCallback void 5 21 22 FrtnZeroCallback This function is called if stc mft frt ocu config t pfnFrtnZeroCallback is defined where n is 0 1 or 2 Callback Function void FrtnZeroCallback void 5 21 23 OcunCallback This function is called if stc mft frt ocu config t pfnOcunCallback is defined where n is 0 1 4 Or 5 Callback Function void OcunCallback void 5 21 24 WfgxyCallback This function is called if stc mft wfg config t pfnWfgxyCallback is defined where xy is 01 23 or 45 Callback Function void WfgxyCallback void 5 21 25 NoiseCancelCallback This function is called if stc mft nzcl config t pfnNzclCallback is defined Callback Function void NoiseCancelCallback void 5 21 26 IcunCallback This function is called if stc m t icu config t pfnIcunCallback is defined where n is 0 1 2 0r 3 Callback Function mota Temeallback word 5 21 27 PpgnCallback This function is called if stc mft ppg config t pfnPpgnCallback is defined where n is 0 2 or 4 MCU AN 300412 E V14 208 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Callback Function void PpgnCallback void 5 21 28 Example Codes Because the
235. ld be used with caution as the full application can get stuck if no further data is received The reception interrupt is used in any case Fujitsu Semiconductor Europe GmbH 159 MCU AN 3004 12 E V 14 Re Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype SMS STK SSC Secese Eher wS pcData time dL ict pul6DataCount Valine LG ic ul6ReadCount boolean t bWait Parameter Name Description in pstcMfs Pointer to MFS instance in out pcData Pointer to reception character data buffer Pointer to variable of characters data being out pul6DataCount actually read Maximum number of characters data to read in ul6ReadCount Ces buffer size must be sufficient TRUE Synchronously wait until uf GReadCount bytes have been received in bWait FLASE Read all available data and return immediately Return Values Description Ok Read data successfully done or started ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved ErrorOperationInProgress An asynchronous transmission is still ongoing while another asynchronous operation should be started 5 20 7 Mfs Write The data provided by Mfs Write pcData is copied into the internal TX buffer and the transmission via TX interrupt is started if not ongoing already Depending on t
236. ling Extif InitArea together with the chip select number area number and the pointer to the configuration Note Extif DeInitArea clears all register of an chip select area This driver does not check the availability of a chip select area of a certain MCU The user has to take care of using the chip select areas correctly e For Type0 device please check SetPinFunc macros which contain accesses to setting EPFR10 UEFEFB to 1 Attention EPFR11 Do not use them for your code Possible missing pins are enabled by If External Bus Interface pins with prefix 1 are provided by the package the user must EPFR11 manually It can be done by the following instruction set the UERLC bit of 5 15 1 Configuration Structure An external memory area has the following configuration structure of the type of stc extif area config t Type Field Possible Description Values i Extif8Bit 8 Bit data bus VELIE cela te Width E a PE Extifl6Bit 16 Bit data bus TRUE Multiplex Mode E MultplexM EOS ELE ne FALSE Non multiplex Mode TRUE Read Byte Mask enable bool t bReadByteMask um a EIE FALSE Read Byte Mask disable ae TRUE Write enable disabled bool t bWriteEnableOff 3 Gg eU Ho Ee FALSE Write enable supported TENT NAND Flash bus enable boolean t bNandFlas
237. lled between SLEEPDEEP 1 and WFI instructions This allows to make some additional application dependent preparations to the deep standby mode MCU AN 300412 E V14 108 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 11 5 Dsm GetRetrunCause This function sets the return cause within a pointered structure of type stc dem return t explained in 5 11 2 If the return cause could not be determined Error is returned otherwise Ok This function should be called early in the user s application to clear the return cause bits Entering deep standby modes will not work correctly if one or more of these bits are remaining Caution The user has to take care that before calling this function all bits of the structure have to be o Prototype SMS SKM TESTER SEUA Cas nee Cem SCS MP SCSRE Enea Parameter Name Description out pstcReturnCause DSM return cause structure Return Values Description Ok At least one return cause could be retrieved Deeg No return cause could be retrieved 5 11 6 HookFunction This function is called between SLEEPDEEP 1 and WEI if stc dsm config t pfnHook is defined Hook Function void HookFunction void 5 11 7 Example Code The following code excerpt shows how to use the DSM functions Assume that INITX LVD Reset and Wake up Pi
238. luence of de initialization of the NVIC use stc exint nmi config t bTouchNVIC to determine whether to touch the corresponding NVIC registers or not Prototype Sa restle Bkume get Delale Ste exime mmi COMEL ie Poretomruig Parameter Name Description in pstcConfig Pointer to NMI configuration structure Return Values Description Ok NMI successfully de initialized ErrorInvalidParameter pstcConfig NULL MCU AN 300412 E V14 122 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 14 8 ExintCallback This function is called if stc exint config t apfnExintCallback n is defined Callback Function Vote Pze COMO ac STIR viene 5 14 9 NmiCallback This function is called if stc nmi config t pfnNMICallbackis is defined Callback Function void NmiCallback void 5 14 10 Example Code 5 14 10 1 External Interrupts The following code excerpt shows how to use the EXINT functions Assume External Interrupt channel O and 1 should be set to falling edge sensitivity Both should get an own callback function include exint h void ExintCallback0 void Do Something o ExintCallbackl void Do something function0 SC Lexi nie COE tags Econo L3 ZERO STRUCT stcExintConfig stcExintConfig abEnable 0 TRUE stcExintConfig aenLevel 0 ExInt
239. m value stcBtConfig0 ul6Duty 0x8000 Just a random value stcBtConfig0 bTriggerIrqEnable TRUE stcBtConfig0 bUnderflowIrqEnable TRUE stcBtConfig0 bDutyIrgEnable TRUE stcBtConfig0 pfnCallback0 Bt0CallbackTg trigger irq callback stcBtConfig0 pfnCallbackl amp BtOCallbackUf underflow irq callback stcBtConfig0 pfnCallback2 Bt0CallbackDe duty irq callback rj pj p p Bt ResetIoSel k Bt Init stc btn t amp BTO amp stcBtConfig0 Init BT instance Enable stc btn t amp BT0 Enable BT instance Bt Trigger stc btn t amp BTO 224 Scans Sue while 1 5 3 18 2 BT in RLT 32 Bit Mode The following code excerpt shows how to use a BT instance as a Reload Timer in 32 Bit mode Fujitsu Semiconductor Europe GmbH 57 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include bt h void Bt0CallbackUf void underflow detection of RLT Do something function Sue JO cole 1 Sesa Ont L3 ZERO STRUCT stcBtConfig0 enMode BtRlt enPrescaler BeEIN Er bRestart TRUE tcBtConfig0 bOutputLow FALSE tcBtConfig0 bOutputInvert FALSE S stcBtConfig tcBtConfig tcBtConfig tcBtConfig0 bTimer32 TRUE OG 0 0 0 0 0 32 bit mode tcBtConfig0 bOneShot FAL 0 0 0 0 0 tcBtConfig0 enExtTriggerMode BtTr
240. measured tcBtConfigl bTriggerIrqEnable FALSE tcBtConfigl bUnderflowIrqEnable FALSE tcBtConfigl bDutyIrgEnable FALSE S S S S S S S S S S S S S tcBtConfig2 enMode BtPwc tcBtConfig2 enPrescaler BtIntClkDiv4 tcBtConfig2 bRestart TRUE tcBtConfig2 bOutputLow FALSE tcBtConfig2 bOutputInvert FALSE tcBtConfig2 bTimer32 TRUE tcBtConfig2 bOneShot TRUE only one measurement tcBtConfig2 enExtTriggerMod BtMeasureHighPulse tcBtConfig2 bCompletionIrgEnable TRUE tConfig2 pfnCallbackO amp Bt2CallbackComplete completion callback 0000000000 if CTRA stesbtnest s eB estCBEGOntsgi rf OR Bt inate ste Otn E BIZ SStCBECONE g2 u8PwcComplete 0 Bt_Enable stc_btn_t amp BT2 Enable PWC Bt Enable stc btn t amp BT1 Start single shot PWM pulse Beater gqgern Steuben EBIN while u8PwcComplete 0 wait for PWC pulse measurement complete while 1 Fujitsu Semiconductor Europe GmbH 61 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 4 CAN Controller Area Network Type Definition SEC cama ic Configuration Type ste can contig t Address Operator CANn First to initialize a CAN module Can Init must be called The callback functions are optional but recommended otherwise there is no report to the A
241. n 1 should be used for returning from deep stop mode Also the SRAM data retention should be set Fujitsu Semiconductor Europe GmbH 109 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include dsm h function0 ste dsm config t steDsmContig L3 ZERO STRUCT stcDsmConfig stcDsmConfig enMode DeepStop tcDsmConfig bLpmPortHiZState FALSE tcDsmConfig bSubClkHdmiCec SE tcDsmConfig bSubClkRtc SI tcDsmConfig bInitxResetReturn TRUE tcDsmConfig bLvdResetReturn I tcDsmConfig bLvdInterrupt tcDsmConfig bRtcInterrupt tcDsmConfig HdmiChannelEnable tcDsmConfig stcWkPinChannelEnabl S S S S S se tcDsmConfig stcWkPinChannelEnabl tcDsmConfig tcDsmConfig se d tcWkPinChannelEnabl tcWkPinChannelEnabl tcDsmConfig stcWkPinChannelEnabl tcDsmConfig stcWkPinChannelEnabl tcDsmConfig WkPinChannelLevel tcDsmConfig bSramRetentionEnable tcDsmConfig pfnHook ve ER se O So ooo C e s D ER H E em ID ID mo om om Dm Dm ID mo ID D o D Write to Back up Registerrs u8DSM BURO1 0x12 ul6DSM BUR0304 0x1234 u32DSM BUR09101112 0x12345678 FM3 CRG gt SCM CTL 0 i celcc HS CR clock or use Chk driver Dam SetMode amp stcDsmConfig 0x12345678 u32DSM BUR09101112 function union uintl6 t ul6ReturnCause stc dsm return t stcReturnCause
242. n pfnCallback Callback function which is called when new CAN message was received and accepted by this message buffer Return Values Description Ok Message buffer has been successfully updated ErrorInvalidParameter pstcConfig NULL e pstcCanInternData NULL Invalid or deactivated CAN unit L3 PREIPHERAL ENABLE CANn pstcMsgBuffer NULL e u8MsgBuf out of range 5 4 7 Can ResetMsgBuffer This function stops any message buffer operation i e disable it In detail it e Stops pending transmission reset TXROST and NEWDAT flag e Stops reception operation reset MSGVAL flag e Resets RXIE and TXIE Clears pointers to external buffers and callback functions I Fujitsu Semiconductor Europe GmbH 67 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Prototype en result t Can ResetMsgBuffer volatile ste Cami t pstcCar blige 16 u8MsgBuf Parameter Name Description in pstcCan CAN instance pointer in u8MsgBuf Message buffer index 0 CAN MESSAGE BUFFER COUNT 1 Return Values Description Ok Message buffer has been successfully updated ErrorInvalidParameter e pstcConfig NULL e pstcCanInternData NULL Invalid or deactivated CAN unit L3 PREIPHERAL ENABLE CANn e u8MsgBuf out of range 5 4 8 CanTxCallback Callback Function
243. nable Dt EnableChannel is set to 0 here and the timer can be enabled via Prototype Sne SUD cite hanne KE emere volatile sue clem Es patenta sue ele Chemnel Sonica Es sice one Gang E u8Channel Parameter Name Description in pstcDt Dual Timer instance pointer in pstcConfig Dt configuration parameters in u8Channel Oor1 Return Values Description Ok Channel configuration has been set nvalidParameter EUIS IS euo tsi NE NULL pstcConfig u8Channel NULL DT CHANNEL COUNT 5 12 5 Dt EnableChannel This function enables the given DT channel by u8Channel Prototype en result t Dt EnableChanel volatile sec chia ue suce imee 16 u8Channel Parameter Name Description Hal parent Dual Timer instance pointer in u8Channel Oor1 Return Values Description Ok Channel enabled ErrorInvalidParameter pstcDt NULL u8Channel DT CHANNEL COUNT Fujitsu Semiconductor Europe GmbH 113 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 12 6 Dt DisableChannel This function disables the given DT channel by u8Channel Prototype entre sut emsabeCHammne vola st ct ness Si uint8 t u8Channel Parameter Name Description in pstcDt Dual Timer instance pointe
244. ne or more configuration data wrong e Wrong enumerator used or enumerator not supported 5 20 5 Mfs_Delnit De Initializes the MFS Use this function for mode change or other changed settings Prototype en sesult t Mics Denit Ste mron TOS e MiS Parameter Name Description in pstcMfs Pointer to MFS instance Return Values Description Ok MFS de initialization successfully done ErrorinvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved 5 20 6 Mfs Read The received data is copied from internal RX buffer filled by RX interrupt into the provided data buffer Mfs Read pcData The size is defined by Mfs_Read pu16ReadCount Depending on the Mfs Read bWait parameter the function behavior is different For an asynchronous non blocking call M s Read bWait FALSE the function will return immediately after all currently available characters in SW ring buffer and HW FIFO are copied into the provided buffer Mfs Read pcData or the maximum count Mfs Read pul6ReadCount is reached The value returned by Mfs Read puReadCount gives the count of characters that was read actually If the referenced MFS does not have a FIFO single data is read For a synchronous blocking call M s Read bWait TRUE the function will return after the requested count of characters Mfs Read pul6ReadCount is received completely This shou
245. nel Buffer a oba je aa E Pointer list to channel buffers 16 bit L3 ADC resolution CHANNELS pu8Priority Buffer a ies wien En He er Pointer list to priority channel buffers L3 ADC 8 bit resolution CHANNELS pul6Priority Buffer i Se ae Es pu Pointer list to priority channel buffers L3 ADC 16 bit resolution CHANNELS LINES ES pu32Dma Pointer to DMA plain data Plain Fujitsu Semiconductor Europe GmbH 39 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Buf fer means original FIFO data Pointer ul6Channel uintl6 t Buffer Count of channel buffers Counter ul6Channel wohl jE Buffer Maximum buffer size or end count EndCount bExternal E a UT MUN TRUE Set external trigger input selection Se FALSE Do not set these bits AnalogInput Eko Hasse P Conversion TRUE Priority conv external start enable External FALSE Priority conv external start disable SERE DPE LOE LE Yo E MC z TRUE Priority conversion timer start enable boolean t Conversion EN UE E FALSE Priority conversion timer start disable MERESEIRE zm ade enPriority AdcPrioIrgFifoLevell IRQ request when result in 1 FIFO stage Ges ee Aa AdcPrioIrqFifoLevel2 IRQ request when result in 2 FIFO s
246. ng this function e Calling this function clears all reset cause bits Prototype Sm cesulic t Raser CGertCausel Ste Treset result r PsreRssule Parameter Name Description out pstcResult Reset cause structure Return Value Description Ok Reset cause bitfield s set 5 24 3 Example Code The following code example shows how to call Reset GetCause correctly MCU AN 300412 E V14 230 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include reset h function stc reset result t stcResetCause Reset cause result structure stcResetCause 0 Reset GetCause stcResetCause if stcResetCause bPowerOn TRUE stcResetCause bInitx TRUE Fujitsu Semiconductor Europe GmbH 231 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 25 RTC Real Time Clock Type Definition SECC Configuration Type stc rtc config t Address Operator RTCn Rtc Init initializes the RTC with the given time and date given in the RTC configuration It also initialized the NVIC if specidfied Rtc SetDateTime allows to set a new date and time Rtc SetAlarmDateTime allows to set a new alarm date and time Rtc EnableDisableInterrupts allows to change the interrupt configurations on runtime without touching the RTC w
247. nne nnne 100 5 10 DMA Direct ett 102 5 10 1 Config ratoM Tcr 102 5102 mac ams a S 103 5 10 3 Dma_Set Chameleon 103 5 104 Dma Enable A 104 5 10 5 Dma Disable E 104 5 10 6 Dra Delmt Channel usina A 104 5 10 7 Br Set Channel Para EE 104 5 10 8 Dma Delnit Channelbaram un 105 5 10 9 DmaCallback EAM xD ME 105 5 10 10 DmaErrorCallback usina 105 MCU AN 300412 E V14 8 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 5 11 5 12 5 13 5 14 5 10 11 Example Code eee eee nene nn emere rennen 105 DSM Deep Standby Modes iie I eerta eoi da s De iii 106 SMEs o 106 5 11 1 1 Structure of stc hdmi channel te 107 5 11 1 2 Structure of stc wkpin channel te 107 5 11 2 Return cause structure stc dem return cause fe 107 5 11 3 Definition for Back up Registers oce enixe ans rapiant n Rob nta dd 108 5 11 4 Per eNOS e 108 5 11 5 Dsm_GetRetrunCause PRO 109 5 11 6 H RT Lungene 109 MINES CuI 9 u 109 DT Dual Tier c 111 5 12 1 Configuration Structure P 111 5 12 2 Dt_Init 112 5 12 3 PN PRK OOP R E PE O R O OP L 112 5 12 4 DE Sec name OM pia 113 PA si M08 ceccccetcsteessso2 EES 113 AA AA A 114 5 12 7 Di WrteLoadChannel vs ida cti 114 5 12 8 DL Witte BOL Gad anne WEE 114 5 12 9 Bret MESTE aure 115 5 12 10 Dt DirectWriteBgLoadChannel eee eee eee eee een 115 5 12 11 BRP ae Mane PEE 11
248. ode iy Error Handling us Zheroneode Mrs ATI iS topi psecMEs T2CRead i if Ok u32ErrorCode Error Handling Step 3 Sequential write Make Dummy data for u8Counter 0 u8Counter lt 8 u8Counter au8TxBuffer u8Counter u8Counter 77 OxAA u8Counter 5 Write data to EEPROM us 2 Errortode MESTA Sitar Ee ER EEPROM 24C04 I2C SLAV ESS I2CWrite Ok u32ErrorCode Error Handling Write address au8TxBuffer 10 0x80 Address u32ErrorCode Mfs I2C WriteSync pstcMfs uint8 t amp au8TxBuffer 10 1 if Ok u32ErrorCode Error Handling Write data sequentially u32ErrorCode Mfs I2C WriteSync pstcMfs uint8 t au8TxBuffer 8 MCU AN 300412 E V14 180 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API k u32ErrorCode Error Handling u32ErrorCode Mfs I2C Stop pstcMfs I2CWrite if Ok u32ErrorCode Brror Handling MfsWait 400000 Give EEPROM 10ms time for writing data internally VE No read access is allowed in this time Step 4 Sequential read back data from EEPROM u32ErrorCode Mfs I2C Start pstcMfs EEPROM 24C04 I2C SLAVE ADDRESS I2CWrite Ok u32ErrorCode
249. ode 0x0A na oy MCU AN 3004 12 E V14 70 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API RX buffer 2 settings assumed response from other CAN node stcMsgBuffer2 stcIdentifier u32Identifier 0x01 stcMsgBuffer2 stcIdentifier bExtended FALSE u32MsgIdMask2 0x00000000 5 4 12 2 Can Initialization and Communication The following code shows an example of CAN initialization and communication with another CAN node using the configuration from above Also here the following callback functions are assumed to be existing CanTxCompleteCb CanStatusCb and CanErrorCb This code assumes a configured and connected external CAN node which is capable to send an auto respond message and a dedicated message by a condition 1 and 2 11 Bit CAN IDs are used After Can Init to 100k Bit s the following message is sent by the MCU Tx D 012h L 8h 70h 61h 52h 43h 34h 25h 16h 70h C 2669h N EF e Rx D 012h L 8h 70h 61h 52h 43h 34h 25h 16h 70h C 2669h A EF Auto Response to ID 012h from external CAN node Rx ID 00Ah L 1h 71h C 3FB5h A EF Message from external CAN node condition 1 Rx ID 001h L 2h 42h 43h C 03EAh A EF Message from external CAN node condition 2 Rx ID 001h L 1h 43h C 04DBh A EF Fujitsu Semiconductor Europe GmbH 71 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver AP
250. ol ic bUseMainClock Gene FALSE Use Sub Clock as input clock boolean t bUseFreqCorr TRUE Use frequency correction value MCU AN 300412 E V14 232 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU FALSE Do not use freguency correction AA ul6FreqCorr Freguency correction value Value ur TRUE Use divider for divider ration boolean t bUseDivider FALSE Do not use divider RtcDivRatio RIN clock division ratio moll No division T Divided by 2 asl Divided by 4 FE enDivider 8 Divided by 8 divider ESOS 16 Divided by 16 rario m3 Divided by 32 64 Divided by 64 128 Divided by 128 236 Divided by 256 512 Divided by 512 int8 t OE o CO r Frequency correction cycle value A Cycle q y y em rte CO w eme os ag sie RES 6 6 Dive co signal of RTC count part is output obl E Days eet Daer CO signal of RTC divided by 2 is output SES FEE stcAlarm SLA Register see below see below register Enable PULSO e u16A11 IME eie MONIES STE FEC w Sekken see below see below interrupts iLinye eese bl ove LE Enable i Er 3 Esp d pfnRead f Callback function pointer for read arglist t callback completion interrupt TES pfnAlarm Callback function pointer for alarm cvn PET Te indie Callback interrupt pfnTimer Callback function pointer for timer UNG PE
251. ompValue Parameter Name Description in pstcQpre QPRC instance pointer in ul6PcRcCompValue New position and revolution count compare value Fujitsu Semiconductor Europe GmbH 221 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 22 10 Qprc SetMaxPositionCount Sets a new Maximum Position Counter Compare value Prototype vold fore Soule Posse somCouine MSc nc Ace Vilas LS jE ul6PcMaxValue Parameter Name Description in pstcQprc QPRC instance pointer in ul6PcMaxValue New maximum position count value 5 22 11 Qprc_GetPositionCount Returns recent Position Count value Prototype bunch t Gore CerrogirtiomCoune Sue Goren pb Psuefore Parameter Name Description battere Stee QPRC instance pointer Return Value Description Balin LS dE Recent position count value 5 22 12 Qprc GetRevolutionCount Returns recent Revolution Count value Prototype vane e me O PDRCOMGSREVOUEOECOUM Sue curca e pareadas Parameter Name Description in pstcQprc QPRC instance pointer Return Value Description pen LS jE Recent revolution count value 5 22 13 Qprc_GetRevolutionCountCompare Returns recent Revolution Count Compare value Prototype vacio e OprenGerRevolurHoneount Compare Sue rp sen UST Siti T Parameter Name Desc
252. on kk Possible values are ON PPG driver supports 16 16 bit mode me TO OERE PEG driver does not supports 656 bust mode KCKCKCKCKCkCkCk Ck kk k Ck k k kCkCk Ck k Ck k Ck Ck CkCkCk Ck kk kk kk kk Ck kCkCk kk kk kk kk Ck Ck kk Ck Ck k Ck Ck k k ck k ck k ck ck kk kk define L3 PPG 1616 MODE AVAILABLE L3 OFF MCU AN 300412 E V14 30 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 4 L3 Main Files In this case the extra configuration elements u16Ppg6Low and ul 6Ppg6High of the PPG s configuration stc mft ppg config t are not compiled to save memory 4 4 7 2 Number of ADC Channels The user can adjust the maximum number of ADC channels by setting L3 ADC CHANNELS to a certain value ck ck ckck KKK KKK KA KA A K A A A A Z A ZAZ AXA A KZ A KAZ A X A A KA ZAZ ck ko A A KA ZA ck ko A ZA A ko ck ck ck ck KA A ko ck ck Sk A ko Sk Mk Sk kk A Xo brief User ADC input configuration Number of analog input pins 1 to 24 KKK CK Ck Ck Ck Ck Ck KKK KKK KKK KKK KKK KKK KKK KK KKK Ck k ck kk kk kk kk kk k ck k ck k ck k ck k ck k ck ck KKK KKK fdefine L3 ADC CHANNELS 16 Note that using smaller numbers than the maximum only skip the left upper channels 4 4 7 3 ADC FIFO depth The user can also set the FIFO depth Normally it should be the same value than L3 ADC CHANNELS ck ck ck ck kk kk Ck Ck ck KAZ A K A A AA KA ZX AX A A X A ZA AX A A KA ZA
253. onfig Q lt wm wm utu uou U W Www tu N toMfi Eit OCcutcomtitqge BEE DIE Eet EO CU ord tFrtOcuConfig SE EE EE EES EO CU ore bTccpOBufferEnable bTccplBufferEnable bTccp2BufferEnable bTcsa0IclrInterrupt bTcsallclrinterrupt bTcsa2IclrInterrupt bTcsa0OIrgzfInterrup bTcsalIrgzfInterrup bTcsa2IrgzfInterrup bExternalClock0Enable bExternalClocklEnable bExternalClock2Enable EO CU e Orc eb OCUCODEd ge EE EE ee EB LOCUCONPHG ibn CU Co DES ee EE HE tb ocu OrbE ge tint O cU Ont E Bets CO GU CUTS CT enClock0 enClockl enClock2 enMode0 enModel enMode2 ul6Frt0Cycle ul6FrtlCycle ul6Frt2Cycle enFrtOcu0Connection enFrtOculConnection enFrtOcu2Connection enFrtOcu3Connection enFrtOcu4Connection enFrtOcu5Connection bOcu0Enable bOculEnable bOcu2Enable bOcu3Enable bOcu4Enable bOcu5Enable bOccpOBufferEnable bOccplBufferEnable bOccp2BufferEnable bOccp3BufferEnable bOccp4BufferEnable bOccp5BufferEnable bOcsaIopOInterruptEnable bOcsaloplInterruptEnable bOcsalop2InterruptEnable bOcsalop3InterruptEnable bOcsaIop4InterruptEnable bOcsaIop5InterruptEnable bRtOHighLevel bRtlHighLevel bRt2HighLevel bRt3HighLevel bRt4HighLevel p D p D p M stcMftFrtOcuConfig NULL nable nable nable Enable Enable tEnable ME ME ME FA FA RA f f MET OER OCU Config instance MET MftPcl
254. ope Soos zadat ask 82 5 5 24 3 Transition to Sub edel 83 5 5 24 4 Transitions and wake up to and from Low Power Modes 84 5 5 24 5 Using CIk GetParameters for configuration set 84 5 6 CRC Cyclic Redundancy Check kaktus aaa amen ubikace 86 5 6 1 Configuration SEH 86 Spa el EE 86 DN 87 5 6 4 Cre PUShB isa 87 Fujitsu Semiconductor Europe GmbH 7 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 0 Contents 203 A ee A Sc ASA erry pe uar nase 87 560 Ore PS okne S dE Du dE MM RE 88 5 6 7 A ET 88 5 6 8 Example Code EE 88 5 6 8 1 Gomgureibhuusmsenmnrerermujednsemeet aup 88 5 6 8 2 CRC without DMA citant 89 5685 GRO With DMA E iia lic 89 ST A A ee E egen 92 WS e il 92 5 7 2 A nn 92 ST A e A 93 5 14 Crirm SetHsReCkDiy sins dans 93 5 7 5 Example Code 0000000 eene nennen AAA AAA tn 93 5 8 CSV Clock Super cT 95 5 8 1 Configuration Structure tia pinitos 95 EEE p CD NE 96 50 A nnet 96 5 8 4 Csv_EnableDisable uo epit erred siete sg sa occ A 96 585 Csv_EnableDisableP ara lucia 97 506 CSV RESO StS cH 97 Bor 9 1 RE EE eet P EEE eee P TE 97 5 8 8 Example Code nnn rnnn nnn nn Ennen nann Ennn Ennn n nennen nnmnnn nennen 98 5 9 DAC Digital Analog ere E 99 5 9 1 Dac SetValueO Dac SetValue1 ue 99 592 Dac Enabled Dac Enabled state 99 5 9 3 Dac DisableD Dac Disable Turilli ett ERE En aS Een 100 5 9 4 Example Code eee en nennen nennen n
255. ork With Rtc EnableDisableAlarmRegisters the comparison to the recent time can be adjusted on runtime Rtc ReadClockStatus reads out the status of the RTC Rtc TimerSet sets the timer value for its interval or one shot counting Rtc TimerStart starts and Rtc_TimerStop stops the Timer With Rtc ReadDateTimePolling the recent date and time can be stored in the pointered configuration structure while the Read Completion Interrupt is temporarily disabled Rtc ReadTimerStatus reads out the Timer status And finally Rtc DeInit allows to de initialize all RTC functions and possible interrupts Also here to touch the NVIC registers can be set Rtc GetRawTime is a helper function which calculates the raw time UNIX time from the RTC time structure stc rtc time t Rtc SetDayOfWeek is a helper function which sets the day of the week calculated from the date and time given in stc rtc time t Rtc SetTime is a helper function which calculates the RTC time structure from the raw time Note This driver module uses the standard C library time h 5 25 1 Configuration Structures 5 25 1 1 RTC Configuration The RTC module uses the following channel configuration structure of the type stc rtc config t Type Field Possible Values Description TR u32RtcClock E Used RTC input clock for sub second register TRUE Use Main Clock as input clock bo
256. orrupted still 0 Bits after erase ErrorTimeout Flash erase or write timed out ErrorOperationInProgress Flash erase or write access not available yet 5 7 4 Crtrim SetHsRcCIkDiv This function sets device type dependent the HS CR clock divider with an argument of type ofen clk hs rc div t as described below Prototype SME STU OTTO SSH SNC CDV ea Clk las re ciy EES RE CK Parameter Name Description in en clk hs rc div t Clock divider see table below Return Values Description Ok Clock divider has be set ErrorInvalidParameter Wrong or unknown enumerator used The type en clk hs rc div t has the following enumerators Device Type ETE ther than 3 Device Type 3 Description HsClkDiv4 HsClkDiv4 HS CR Clock is divided by 4 HsClkDiv8 HsClkDiv8 HS CR Clock is divided by 8 k k HsC1kDiv16 HsClkDivl6 HS CR Clock is divided by 16 HsClkDiv32 HsClkDiv32 HS CR Clock is divided by 32 HsClkDiv64 HS CR Clock is divided by 64 k k k HsC1kDiv128 HS CR Clock is divided by 128 HsClkDiv256 HS CR Clock is divided by 256 HsClkDiv512 HS CR Clock is divided by 512 5 7 5 Example Code The following example shows how to use the CRTRIM driver module s functions Fujitsu Semiconductor Europe GmbH 93 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 R
257. plications it is impossible that a driver library can cover each use case Therefore the LLL was designed to cover as most of the basic possible setting for each implemented resource It might be possible that a combination of several driver parts may lead to malfunction although it was attentively tested This chapter gives an overview of known restrictions of the LLL 6 2 Resource Activation Because of the wide portfolio of the FM3 family it would be too complex to build in a preprocessor logic to determine a peripheral and a certain instance availability for each derivative The user has to check by himself via the datasheet for existence of a peripheral and a certain instance for his device 6 3 Interrupt Handler Enumerator Names It may happen that some defined Interrupt handler names in the startup mb9 ab xyz s files are not the same as used in the interrupts c file of the LLL Please adjust the names in the startup files to those used in interrupts c Example Devices with CAN and without Ethernet have the handler name CANn IROHandler where devices with both resources share the interrupt and have the name ETHER CANn IROHandler In the IAR environment the adjustment of the example above has to be done at marked lines in the code excerpt below MODULE cstartup Forward declaration of sections SECTION CSTACK DATA NOROOT 3 SECTION intvec CODE NOROOT 2 EXTERN iar program start EXTERN SystemIn
258. polling routines a similar hook function like in 3 c is called static void L3 RAMCODE WAIT LOOP HOOK void KEKKKKK AKA ck KA KA A KA A AZ A KAZ kk AX A A AA ck ko A kk A KA KAZ A ko A A KA ZA ck ko A A ko A ZA ck ko A KA A ko ck ck ko ck k ko ko ko kx ko ko brief Hook function which is called from polling loops KR This functionality should be the same as in 13 c Fe KKK KKK k kc A k kc k Ck k KKK KK KKK KKK A ifdef ICCARM ramfunc elif CC ARM attributes section ramfune N else error Please check compiler and linker settings for RAM code endif static void L3 RAMCODE WAIT LOOP HOOK void Place code for triggering Watchdog counters here if needed This function may be filled with user code if needed It should represent the same functionality as described in chapter 4 2 5 23 1 NMI Handling Because NMI is by definition non maskable it may also occur if RAMCODE is executed In this case the switch off Flash Memory Read would cause an bus error because the NMI vector can not be fetched Therefore the Flash erase and programming routines disable all other interrupts patch the interrupt vector table to RAM location and set at the correct offset a RAM vector for the NMI This vector points to a temporary RAM NMI service routine ck ck ck ck kk kk ck Ck ck KAZ A KA A AKA KA kk kk A X A ZA AK A A KA ZA AK AA KA ZA ZK A A ZA kk A A k KA kA A A ko ko kck k
259. r in u8Channel Oorl Return Values Description Ok Channel disabled ErrorlInvalidParameter pstcDt NULL u8Channel DT CHANNEL COUNT 5 12 7 Dt WriteLoadChannel This function writes to the load register of the given DT channel via configuration pstcConfig by u8Channel Prototype en sesuillt tt DE Wrtteloadthannel ee enee eegen pstcDt See hr Chennel cori us ps ee one vimes 16 u8Channel Parameter Name Description in pstcDt Dual Timer instance pointer in pstcConfig DT configuration parameters in u8Channel Oor1 Return Values Description Ok Channel disabled ErrorInvalidParameter pstcDt NULL e u8Channel gt DT CHANNEL COUNT 5 12 8 Dt WriteBgLoadChannel This function writes to the background load register of the given DT channel via configuration pstcConfig by u8Channel MCU AN 300412 E V14 114 Fujitsu Semiconductor Europe GmbH Low Level Library Manual J Chapter 5 L3 Resource Driver API FU ITSU Prototype en result t Dt WriteBgLoadChannel volatile stc dtn t pstcDt sre annie Conti t Size Sontag wineg 1 u8Channel Parameter Name Description taes nede Dual Timer instance pointer in pstcConfig DT configuration parameters in u8Channel Oorl Return Values Description Ok Channel disabled ErrorlInvalidParameter pstcDt NULL e u8Channel gt
260. r h e The configuration en clk pll src t PllSrcClkHc and the function Clk SetPllSource can only be used if the used device supports HS RC Clock as PLL input clock source This driver does not check for availability e Because the Clock interrupts are shared with other interrupts e g Watch Counter Clk SetIrg has an argument whether to touch the NVIC registers or not to prevent interference with other driver part The CLK driver functions may replace the System Init clock settings in system mb9 ab xyz c Set the definition for CLOCK SETUP to 0 in system mb9f ab xyz h in this case The availability of PLL connected to HS CR clock by PrNC bit is not checked by the L3 Please refer to device s datasheet 5 5 1 Configuration Structure The CLK module uses the following configuration structure of the type stc c1k config t Possible XM T Field Description ype Values p ClkMain Main Clock Oscillator ClkSub Sub Clock Oscillator lk t S ON GFK seurce n ClkHsCr High Speed CR Clock Oscillator ClkLsCr Low Speed CR Clock Oscillator Fujitsu Semiconductor Europe GmbH 73 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API C1kP11 PLL Cloc
261. r o ro EE se O Fujitsu Semiconductor Europe GmbH 215 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API PpgConfig u8Ppg0Low 0x20 PpgConfig u8Ppg0High 0x80 PpgConfig u8Ppg2Low 0x30 PpgConfig Ppg2High 0x90 PpgConfig u8Ppg4Low 0x40 PpgConfig u8Ppg4High OxA0 PpgConfig enPpgOTrigger MftPpgTriggerRegister PpgConfig enPpg2Trigger MftPpgTriggerRegister PpgConfig enPpg4Trigger MftPpgTriggerRegister PpgConfig bPpgOStartLow FALSE PpgConfig bPpg2StartLow FALSE PpgConfig bPpg4StartLow FALSE PpgConfig enPpgCompareCl EPpgPelk2 PpgConfig u8Ppg0Compare 0 PpgConfig u8Ppg2Compare 0 PpgConfig u8Ppg4Compare O PpgConfig pfnPpgOCallback NU PpgConfig pfnPpg2Callback NU PpgConfig pfnPpg4Callback NU ID ID mo VUV UVU D mm A U Gh Gh ch Gh daada Ee E ctos Gh Gh Gh ck ct MER nat SCE mE EA EA MERO MFT instance amp stcMftFrtOcuConfig FRT OCU configuration amp stcMftWfgConfig WFG configuration NULL NZCL configuration NULL ICU configuration NULL ADCMP configuration tcMftPpgConfig PPG configuration pstcMft stc mftn t amp MFTO Setup pointer to MFTO instance Mft FrtStart pstcMft TRUI TRUI TRUI Start ERTO SER ERTI i Stare ERT E E El ws se Start PPGO PPG2 PPG4 Mft PpgSwTrigger pstcMft TRUE T
262. r starts FRTO first then FRT1 and at last FRT2 Same appears to Mft FrtStop which stops the FRTs given in the function arguments FRTO is stopped first and FRT2 at last Mft FrtRead reads out the recent FRT counter value MCU AN 300412 E V14 186 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Each FRT and OCU interrupt has an own callback function The pointer to these user functions can be defined in the stc mft frt ocu config t configuration If an interrupt is enabled in the configuration the driver s ISRs are taking care of clearing the interrupt cause and calling the callback functions if their pointers are unequal to NULL The OCU channels can be enabled by Mft Init orlater enabled or disabled individually by Mft OcuStartStop with their configuration stc m t frt ocu config t The ICU channels are not enabled by Mft Init For individually en and disabling ICU channels by its configuration Sto mft icu config t the function Mft IcuStartStop is used Mft IcuRead reads out the captured FRT value of an selected ICU channel and can be called in the ICU s channels corresponding callback function This driver only configures and handles the PPG channels 0 2 and 4 for MFTO and channels 8 10 12 for MFT1 because only these channels are connected to the WFG outputs Defining configurations for all PPGs for in
263. r to MFT instance in u8PpgNumber 0 2 4 means PPG0 2 4 in ul6LowValue 16 Bit PPG low pulse value in ul6HighValue 16 Bit PPG high pulse value Return Values Description Ok Dedicated PPGs set with new values ErrorlInvalidParameter joies NU PPG number out of range or wrong 5 21 16 Mft PpgSetValue8plus8 Set new 8 8 bit PPG values of an MFT instance Use this function only if PPG is set to 8 8 Bit mode Prototype SMS STK v Mre Eeer ugeet Et ste mien E josiccMicie ane E u8PpgNumber timege u8PscLowValue varmes u8PscHighValue blalighete E u8LowValue vimes E u8HighValue Parameter Name Description in pstcMft Pointer to MFT instance in u8PpgNumber 0 2 4 means PPG0 2 4 in u8PscLowValue 8 Bit Prescaler low pulse value in u8PscHighValue 8 Bit Prescaler high pulse value in u8LowValue 8 Bit PPG low pulse value in u8HighValue 8 Bit PPG high pulse value Return Values Description Ok Dedicated PPGs set with new values ErrorInvalidParameter pstcMft NULL e PPG number out of range or wrong MCU AN 300412 E V14 206 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 21 17 Mft Ppglgbt Init Init PPG IGBT module MFTn PPG must be initialized properly before calling this function This function does not enable the IG
264. re If Csv EnableDisableParam is used instead of Csv EnableDisable the configuration stc csv config t can be purged on runtime after initialization Notes The clock s to be supervised must be enabled and stable For anomalous frequency detection the High Speed CR must be trimmed 5 8 1 Configuration Structure The configuration structure of type of stc csv config t consists of Type Field Possible Description Values TRUE Main Clock Supervisor enabled boolean t bMainCsvEnable E FALSE Main Clock Supervisor disabled TRUE Sub Clock Supervisor enabled boolean t bSubCsvEnable E FALSE Sub Clock Supervisor disabled Freguency Count Supervisor boolean t bFcsEnable o enabled d FALSE Frequency Count Supervisor disabled TRUE FCS Reset enabled boolean t bFcsResetEnable FALSE FCS Reset disabled TRUE FCS Interrupt enabled boolean t bFcsIrgEnable f E E FALSE FCS Interrupt disabled TRUE FCS IRQ is cleared in driver ISR boolean t bFcsIrgAutoClear FCS IRO is not cleared in driver FALSE ISR CsvFcsFreq ing ON OSV fes e Eo E Sv d req Count cycle setting alli um Div256 1 256 freguency of HS CR clock Fujitsu Semiconductor Europe GmbH 95 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Div512 1 512 f
265. reguency of HS CR clock Div1024 1 1024 frequency of HS CR clock ae ul 6Freqency S Frequency detection window lower WindowLower setting eae ul6Fregency E Frequency detection window upper WindowUpper setting oer fune orr t EE 8 FCS interrupt callback function P uintl6 t with uint16 t argument The argument for the CSV Callback function is the value of the FCSWB CTL register 5 8 2 Csv Init This function initializes and enables the Clock Supervisor according the configuration Prototype Sme SK Cey Job ere csy Contig E ses e one Parameter Name Description sie conti Pointer to CSV configuration structure Return Values Description Ok CSV has been initialized successfully ErrorInvalidParameter pstcConfig NULL Invalid FCS count cycle setting 5 8 3 Csv Delnit This function de initializes and disabled the Clock Supervisor completely Prototype en result t Csv DeInit void Return Values Description Ok CSV has been de initialized successfully 5 8 4 Csv EnableDisable This function en or disables the FCS Main CSV and Sub CSV according to the configuration Also the FCS interrupt and its auto clear option can be en or disabled with this function Cou Init must be called before Prototype SMS STE Cey melos Ge Eolo t Se CO Parameter Name Descr
266. rent PPG modulation and different WFG dead times Fujitsu Semiconductor Europe GmbH 211 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include mft function Ste mieti ECE Ocu Contig e Sb cMEEBEPOcCucomki gum METE RT AO conf Sit cem WCC Dist cete stcMftWfgConfig MFT WFG configuration Sie CXII IS GC ODE ol stcMftPpgConfig MFT PPG configuration Sie RETI E TNCS pstcMft NULL MFT instance ZERO STRUCT stcMftFrtOcuConfig 3 ZERO STRUCT stcMftWfgConfig ZERO STRUCT stcMftPpgConfig i ERT settings tcMftFrtOcuConfig enClock0 tcMftFrtOcuConfig enClockl tcMftFrtOcuConfig enClock2 tcMftFrtOcuConfig enModeO tFrtOcuConfig enModel UpDownCount tFrtOcuConfig enMode2 UpDownCount tFrtOcuConfig bTccpOBufferEnable Im tFrtOcuConfig bTccplBufferEnable tFrtOcuConfig bTccp2BufferEnable tFrtOcuConfig bTcsa0IclrInterruptEnable tFrtOcuConfig bTcsallclrInterruptEnable tFrtOcuConfig bTcsa2IclrInterruptEnable tFrtOcuConfig bTcsa0IrqzfInterruptEnable tFrtOcuConfig bTcsallrqzfInterruptEnable tFrtOcuConfig bTcsa21IrqzfInterruptEnable tFrtOcuConfig bExternalClockO0Enable tFrtOcuConfig bExternalClocklEnable tFrtOcuConfig bExternalClock2Enable 8 tFrtOcuConfig ul6Frt0Cycle 0x1234 tFrtOcuConfig ul6FrtlCycle eit A tFrtOcuConfig ul6Frt2Cycle 0x1234 tFrtOcuConfig enFrtOcu0Connection MftFrt0Ocu tFrtOcuConfig enFrtOculConnection MftFrt0O
267. res with the Hardware Watchdog Timer the same interrupt vector The driver recently only support External Interrupt channels from 0 15 5 14 1 Configuration Structures 5 14 1 1 External Interrupts The EXINT module uses the following channel configuration structure of the type stc exint config t for external interrupt except NMI Type Field Possible Values Description abEnable TRUE Ext Int channel enabled boolean t M s L3 EXINT CHANNELS FALSE Ext Int channel disabled ExIntLowLevel Low Level detection en exint aenLevel ExIntHighLevel High Level detection level t L3 EXINT CHANNELS ExIntRisingEdge Rising Edge detection ExIntFallingEdge Falling Edge detection apfnExintCallback Array of callback function TUNE DEE E m a Se L3 EXINT CHANNELS pointers for each channel L3 EXINT CHANNELS is defined in 3 user h and determines the maximum number of available external interrupt channels MCU AN 300412 E V14 120 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 14 1 2 None maskable Interrupt NMI The EXINT module uses the following channel configuration structure of the type stc exint nmi config t for NMI Type Field Possible Values Description TRUE NVIC is touched boolean t bTouchNVIC FALSE NVIG is not touched func ptr t mem Sines fun
268. ress even of data lash WriteBlock8 0x4008 au8FlashPat est even address odd of data lash WriteBlock8 0x4010 au8FlashPat Test odd address even of data lash WriteBlock8 0x401D au8FlashPat Test odd address odd on dat lash WriteBlock8 0x4025 au8FlashE n Test of Flash WriteBlock16 Flash WriteBlock16 0x4030 aul6FlashPattern 3 Erase Sector SA4 with wait lower bank Flash Erase 0x00200000 Write even then odd address Flash Write8 0x00200004 0x55 Flash Write8 0x00200005 OxAA MCU AN 300412 E V14 142 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 17 FLASHTIMING Flash Timing Functions Type Definition Configuration Type Address Operator The following functions can set Flash timings for Main and Work Flash Depending on the Device Type some functions are available and some not The following table shows an overview of the functions and availability depending on the Device Type Device Type Function LENS BEE Flashtiming GetFlashBufferStatus V V Flashtiming EnableFlashBuffer v v Flashtiming DisableFlashBuffer y y Flashtiming SetFlashSyncDown v y y y y y y Flashtiming SetFlashWait v v v v v Flasht
269. ription in pstcQprc QPRC instance pointer Return Value Description Dado he Recent revolution count compare value 5 22 14 Qprc GetPositionRevolutionCountCompare Returns recent Position and Revolution Count Compare value MCU AN 300412 E V14 222 O Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Prototype wimnele e Qore Conosco OOo Compare SCO RSS c HC Parameter Name Description in pstcQprc QPRC instance pointer Return Value Description blas JE Recent position and revolution count compare value 5 22 15 Qprc GetMaxPositionCount Returns recent Maximum Position and Revolution Count value Prototype wineleg u Qore CaolbxPosteioaCoume ste Gprten t7 pstefs re Parameter Name Description in pstcQpre QPRC instance pointer Return Value Description Recent Maximum Position and Revolution Count value alone LS dE 5 22 16 Qprc GetPositionrevolutionCount Device Types z 3 allow to read the Position and Revolution count at once 32 Bit access can use this function The result is stored in a structure of the type of stc gpre pos rev count t as follows Structure Type SEC qpre pos rev count t Type Field Description umele e ul6PositionCount Recent Position Count uintl6 t ul6Revol
270. river API 5 3 16 Callback1 This function is called if stc bt config t pfnCallback1 is defined and the according interrupt is enabled It is called by IRQO Callback Function void Callback1 void 5 3 17 Callback2 This function is called if stc bt config t pfnCallback2 is defined and the according interrupt is enabled It is called by IRQO Match in duty in PWM function Callback Function void Callback void 5 3 18 Example Code The following code excerpts shows some applications of using the BT driver 5 3 18 1 BT in PWM Mode The following code excerpt shows how to use a BT instance as a Pulse Width Modulator MCU AN 300412 E V14 56 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API fine lade be HY void Bt0CallbackTg void trigger callback of PWM Do something Bt0CallbackUf void underflow detection of PWM Do something BtOCallbackDc void duty cycle of PWM Do something function ste bt Contig it steBECon 190 L3 ZERO STRUCT stcBtConfig0 stcBtConfig0 enMode BtPwm stcBtConfig0 enPrescaler BtIntClkDiv16 stcBtConfig0 bRestart TRUE stcBtConfig0 bOutputLow FALSE stcBtConfig0 bOutputInvert FALSE stcBtConfig0 bTimer32 FALSE PWM has no 32 bit mode stcBtConfig0 bOneShot FALSE stcBtConfig0 enExtTriggerMode BtTriggerDisable stcBtConfig0 ul6Cycle 0xC000 Just a rando
271. rom the MFS channel Prototype Char t Mre erar hara Sue mien e MTS SS ts MS boolean t bWait Parameter Name Description in pstcMfs Pointer to MFS instance TRUE Synchronously wait until reception complete in bWait M EE FALSE Do not wait Return Values Description char t Read character 5 20 14 Mfs WriteString Writes a 0 terminated string to MFS module synchronously or asynchronously The characters provided by Mfs WriteString pcData is copied into the internal Tx buffer and the transmission via Tx interrupt is started if not ongoing already Depending on the Mfs WriteString bWait parameter the function return behavior is different For an asynchronous non blocking call Mfs WriteString bWait FALSE the free size of the internal buffer must be sufficient to take all data M s Write pcData of length M s Write ul6DataLength otherwise the function will return ErrorBufferFull After all data is copied into the internal buffer the function will return immediately The transmission may be pending when the function returns For a synchronous blocking call M s WriteString bWait TRUE the function will wait until all data is transferred to the MFS hardware FIFO The transmission may be pending when the function returns If the referenced MFS does not have a FIFO single data is transferred Note no error checking is done while reading from
272. rope GmbH 127 MCU AN 3004 12 E V 14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API Definition fdefine Extif Nand SetAddress base adr N Otaku some ces 5 315 CME TST PNA DAD DR EORR SES X unsigned char addr Parameter Name Description in base Base address of used chip select area in adr 8 Bit address part 5 15 6 Extif_Nand_ReadData This pseudo function reads 8 Bit data from the external bus if configured as NAND Flash bus Definition define Extif Nand ReadData base volatile unsigned char base EXITIF NAND DATA OFFSET Parameter Name Description in base Base address of used chip select area Return Value Description char 8 Bit read data 5 15 7 Extif Nand WriteData This pseudo function writes 8 Bit data to the external bus if configured as NAND Flash bus Definition define Extif Nand WriteData base data volatile unsigned char base EXITIF NAND DATA OFFSET X unsigned char data Parameter Name Description in base Base address of used chip select area in data 8 Bit data to be written 5 15 8 Extif Nand ClearAle This pseudo function de asserts the ALE MNALE signal Definition fdefine Extif Nand ClearAle base volatile unsigned char base EXITIF NAND ALE
273. roperly 5 5 24 3 Transition to Sub Clock Assume a transition form PLL clock to Sub Clock run mode tinclude Wolk ht define SUB CLOCK STABILIZATION TIMEOUT 200000000 Time out count for Sub clock stabilization define CLK SOURCE TRANSITION TIMEOUT 2 Time out for clock source ee transition only 2 E erials 1E clock is 74 stabilized function store contig e secelkcontig L3 ZERO STRUCT stcClkConfig EnableSubClock k Clk WaitForSubOscillator SUB CLOCK STABILIZATION TIM Error handling here stcClkConfig enSource stcClkConfig bEnableSubClock stcClkConfig bEnableMainClock FA stcC1kConfig bEnableP11 FA k Clk SetSource amp stcClkConfig Ok Clk WaitForClockSourceReady ClkSub CLK SOURCE TRANSITION TIM Error handling here Fujitsu Semiconductor Europe GmbH 83 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 5 24 4 Transitions and wake up to and from Low Power Modes The following example shows how an external interrupt is used to wake up an MCU from timer sleep or stop mode The configuration and API of the external interrupts are explained in detail in chapter 5 13 tinelude cik HY tinclude exint h KKK KK Ck kk KA kk kk AKA KA AKA KA AKA KA AKA kck kc k kck kc k kc k kc k kc k kck kc k kc k KKK KKK KKK KKK KKK KK KK k kk Eternal interrupt Ch 0
274. rtl Connects FRT1 to ICU3 cu TM rn MftIcuFrt2 Connects FRT2 to ICU3 Me LCU e ENEE Connects FRTO to external MFT 1 Mit ie ue EME Connects FRTO to external MFT 2 MCU AN 300412 E V14 194 Fujitsu Semiconductor Europe GmbH Chapter 5 L3 Resource Driver API Low Level Library Manual FUJITSU MftIcuDisable Disables ICUO STEM CSU I 0Ed MftIcuRisingEdge Sets ICUO rising edge detection edge t ens cu 399 wrtIcuFallingEdge Sets ICUO falling edge detection MftIcuBothEdges Set ICUO both edges detection See above for ICU1and ICU2 MftIcuDisable Disables ICU3 Sm me LCU w I 3Ed MftIcuRisingEdge Sets ICU3 rising edge detection edge t en Ccus5909 mftIcuFallingEdge Sets ICU3 falling edge detection ES MftIcuBothEdges Set ICU3 both edges detection prevo CUTS HE MUR TRUE Enables ICUO interrupt Sze TALSE Disables ICUO interrupt Enable See above for ICU1and ICU2 MEUS Kon se TRUE Enables ICU3 interrupt B ES debes Disables ICU3 interrupt Enable DAME Pointer to ICUO interrupt callback ELIAS SEE E Callback function See above for ICU1and ICU2 PACE Pointer to ICU3 interrupt callback Emma JOE dE Callback function 5 21 1 5 ADC Compare Configuration The ADCMP has the configuration of the type of stc mft adcmp config t Type Field Possible Values Description M
275. s The following code excerpt examples shows how to handle the MFS functions 5 20 35 1 Asynchronous Communication via Configuration This code shows some functions for asynchronous communication It assumes a connected serial remote station which can also receive and transmit MCU AN 300412 E V14 174 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API include mfs h define BUFFERSIZE 256 char cRxBuffer BUFFERSIZE Reception Ring Buffer char cTxBuffer BUFFERSIZ Transmission Ring Buffer uint32 t u32CountTxCb uint32 t u32CountRxCb void MfsOTxCallback void u3ZCountTxeb void MfsORxCallback void u32CountRxCb function SECHMESRCONELOMERSAECCOMEUS MES configuration SCE MESIE pstcMfs NULL MFS instance L3 ZERO STRUCT stcConfig char au8ReadBuffer 256 const uint8 t cszString Hello world uintl6 t ul6ReadCount tcConfig enMode MfsAsynchronous0 tcConfig enClockSource MfsUseInternalBaudRateGenerator tcConfig u32DataRate 115200 tcConfig enParity MfsParityNone tcConfig enStartStopBit MfsOneStartOneStop tcConfig u8CharLength MfsEightBits EcCon fig bBitDi rection 0 BOB aE LS SE tcConfig bSyncClockInversion FALSI tcConfig bSyncClockOutputDelay FALSE tcConfig pcTxBuffer cTxBuffer Tx Ring Buffer tcConfig ul6TxBufferSize BU
276. s supported by the device this threshold voltage is also set by this function Prototype Sa restle Lyd Imitrrol ste lye eme er je jaseeCGomisile Parameter Name Description in pstcConfig Pointer to LVD configuration structure Return Values Description Ok LVD Interrupt initialization successfully done ErrorInvalidParameter e pstcConfig NULL Wrong or not supported Interrupt voltage e Wrong of not supported Reset voltage 5 19 3 Lvd Delnitlrq Disables the LVD interrupt Note that the user s reset voltage if supported is retained Prototype en este 6 vo MNT Smetona ME OR GT Return Values Description Ok LVD Interrupt de initialization successfully done 5 19 4 LvdCallback This function is called if stc 1vd config t pfnCallbackis is defined Callback Function void LvdCallback void 5 19 5 Example Code The following code excerpt shows how to use the LVD functions include lvd h void LvdCallback void Hit if voltage is below 4 0 Volts function ste Led config t stcLdvConfig L3 ZERO STRUCT stcLdvConfig LvdIrqVoltage40 Threshold 4 0 Volts amp LvdCallback stcLdvConfig enIrqVoltage stcLdvConfig pfnCallback Lvd InitIrq amp stcLdvConfig MCU AN 300412 E V14 152 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5
277. s may contain NULL then Prototype sm resler Rue mie volearile gte ren ts PSizcRec SES mee mt EN pstcConfig HEG TES ble 18 psech Ge meda alarm ic pstcAlarm boolean t bTouchNvic Description Parameter Name in pstcRtc RTC instance pointer in pstcConfig Pointer to RTC configuration in pstcTime Pointer to time structure in pstcAlarm Pointer to time alarm structure ee EE TRUE Init NVIC registers QuE o y FALSE Do not touch NVIC registers Return Value Description Ok RTC successfully initialized ErrorlInvalidParameter pstcRtc NULL e psteConfig NULL e pstcTime NULL pstcAlarm NULL pstcMfsInternData NULL Instance could not be resolved Other wrong setting or enumerator used 5 25 4 Rtc Dein This function de initializes the RTC module Prototype SMS UNO CEE CHD SHK ON EMO SrO rrn O SEE REC boolean t bTouchNvic Parameter Name Description in pstcRtc RTC instance pointer SN BIOUSENVIS TRUE De Init NVIC registers FALSE Do not touch NVIC registers Return Value Description Ok RTC successfully de initialized ErrorInvalidParameter psteMtt NULL Fujitsu Semiconductor Europe GmbH 237 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 25 5 Rtc SetDateTime This function builds two 32
278. se and Programming Routines enne 135 5161 Flash Erase oie rt t ki sais Etpa tii 135 516 2 A issii aani 135 5 16 39 Flash LU dico mte MD a EO E P EET 136 5 16 4 Flash BOKS canciller ici ERR ter bd rptu ds 137 5 16 5 FN PR EE 137 5 16 6 Sr Mercede En 138 5 16 7 Example Code sse nennen nennen nenne nennen nnns 139 5 16 71 Devices with Single Flash nente teta tenax nnne 140 9 10 72 Devices with Work Fassa dasad ida neumi doa u adips 141 5 16 7 3 Devices with Dual Operation Flash 142 FLASHTIMING Flash Timing Functions ocococonccccccnonccccccnnnoncnncnonancnn canon cnn nana no 143 5 17 1 Flashtiming_GetFlashBufferStatus ii 143 5 17 2 Flashtiming EnableFlashBuffer ue 143 5 17 3 Flashtiming DisableFlashBuffer ue 144 5 17 4 Flashtiming SetFlashSyncDown sss 144 5175 Flashtiming_SetFlashWait odium tsia nube alui az bona Bungie oia 145 5175 Flashtiming_SetWorkFlashWait cts i 145 5 17 7 Example Code eee eee ener nene 146 GPIO General Purpose POS iso dno reap ii 147 roe Es oad Ma 0 0 0 06 001110 ee 147 MCU AN 3004 12 E V14 10 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 0 Contents 5182 SPOT Pith MIO d CP 148 518 B E A P P O O MES 148 5 18 4 SRO DIN Pias EE 148 5 18 5 BPIRFURGPINN ME EE 148 5 18 6 Example Code sse seen enne enne 149 5 19 LVD Low Voltage Detection see iius tnr evne 150 5 19 1 Configuration Structure sii
279. se of the external LIN transceiver every data transmission and or reception is always read completely to the reception buffer 5 20 1 Transmission Ring Buffer Principle The following illustration shows how the transmission ring buffer works User Tx Buffer Internal Tx Ring Buffer Figure 5 2 Transmission Ring Buffer Principle The transmission data is transferred from the user transmission buffer to the internal ring buffer This internal buffer is used then to generate the serial output afterwards Note that the hardware Tx FIFO between ring buffer and serial output is not drawn here 5 20 2 Reception Ring Buffer Principle The following illustration shows how the reception ring buffer works User Rx Buffer Internal Rx Ring Buffer Figure 5 3 Reception Ring Buffer Principle Fujitsu Semiconductor Europe GmbH 155 MCU AN 300412 E V14 Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU The reception data first is stored in the internal ring buffer From this ring buffer the data is transferred to the user reception buffer Note that the hardware Rx FIFO acting as intermediate buffer after reception and ring buffer is not drawn here 5 20 3 Configuration Structures The MFS module uses the following configuration structures 5 20 3 1 Asynchronous synchronous and IPC Mode The configuration structure of the type of stc mfs t for all modes other than Lin mode is
280. sk tIF u8AreaAddress X D x x X D x x x x x X X x x x x x x x X x x x x Qu uo 0 ou U uo unu utu niu 0 tu tif1MB uint8 t EXTIF NAND ADDRESS gt gt 20 x x Ej Di E Ed Hd D Bj Dd D Ej Hd ub Dj Dd D B d ud DJ X a Eb am pi opi pl p pd p pd EE SUC x for u323 07 0823 lt 51257 32555 ii Clear buffer au8Buffer u32i 0 if Extif InitArea EXTIF AREA amp stcExtIF Nand ReadID amp u8MarkerCode amp u8ld Read NAND Flash ID Fujitsu Semiconductor Europe GmbH 133 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API u32Block u32Page if NAND FLASH Erase fail Nand ReadPage u au8Buffer for u32i 0 au8Buffer u32 NAND FLASH I Write fail for u32i 0 au8Buffer u32 Nand ReadPage u au8Buffer if NAND FLASH 1 Erase fail Nand ReadPage u au8Buffer ZA duse a value Juste value ERROR Nand EraseBlock u32Block ed 32Block u32Page amp au8Buffer 0 now should contain all OxFF erased NAND Flash cells u32i lt 512 u32i Make some data i uint8 t 0xFF amp u32i ERROR Nand WritePage u32Block u32Page amp au8Buffer 0 ed 825232801 Ne Sr
281. sn MESi NULL 1 NULL amp stcConfig not used Setup pointer to MFS instance Fujitsu Semiconductor Europe GmbH 177 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Z ol Tx Buffer au8TxBuffer 0 0x11 Some meaningful command for SPI slave au8TxBuffer DESDE au8TxBuffer 05997 au8TxBuffer 0x44 au8RxBuffer 0 Clear reception buffer not needed au8RxBuffer 0 au8RxBuffer 0 0 au8RxBuffer Transfer 4 bytes SPI command Mfs SynchronousTransfer pstcMfs uint8 t amp cTxBuffer uint8 t amp cRxBuffer 4 Fill Tx Buffer with dummy bytes SOT remains mark level on next 2 frames au8TxBuffer 0 OxFF au8TxBuffer 1 OxFF Now receive 2 bytes SPI slave response Mfs SynchronousTransfer pstcMfs uint8 t amp cTxBuffer uint8 t amp cRxBuffer VE au8RxBuffer contains the SPI slave response now if au8RxBuffer 0 0x99 amp amp au8RxBuffer 1 0x88 That was the answer w xpected from the SPI slave Mfs DeInit pstcMfs 5 20 35 4 C Communication The following code example shows how to establish an I C communication acting the MES as master It is assumed that the slave is an serial C EEPROM The example does the following steps 1 Write a single byte 0x12 to the EEPROM s address 0x80 and wait 10ms 2 Read back t
282. stc rtc config t pfnOneSecondCallback is defined and the according interrupt is enabled Callback Function void OneSecondCallback void 5 25 24 OneMinuteCallback This function is called if stc rtc config t pfnOneMinuteCallback is defined and the according interrupt is enabled Callback Function void OneMinuteCallback void 5 25 25 OneHourCallback This function is called if stc rtc config t pfnOneHourCallback is defined and the according interrupt is enabled Callback Function void OneHourCallback void 5 25 26 Example Codes 5 25 26 1 RTC The following code example shows how to use the RTC driver MCU AN 300412 E V14 244 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API tinc lude url Ch stc eto Combo te Ee recommended to be global SEC AE E hee E z recommended to be global ste rte alarm stcRecAlarm recommended to be global void Rtc ReadCallback uint8 t u8RcbSecond uint8 t u8RcbMinute uint8 t u8RcbHour uint8 t u8RcbDay uint8 t u8RcbDayOfWeek uint8 t u8Month uint8 t u8Year some action function time t tRawTime SECCO SCRI CC CC CC BC CC CC CC CC CC LC CC CC CC CC CC CC CC CC BC LC CC CC CC CC CC CC tcConfig u32RtcClock DOPO tcConfig bUseMainClock TRUE tcConfig bUseFreqCorr FALSE tcConfig ul6FreqCorr
283. stcAdc0 while 0 u8ConversionDone Dma DeInit Channel amp stcDmaConfig MCU AN 300412 E V14 48 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 3 BT Base Timer Type Definition SEG leia t Configuration Type BT ste DL concio Configuration Type BTIOSEL stc bt iosel config t Address Operator BTn To initialize a BT instance use Bt_Init After this the BT instance can be enabled by Bt Enable and disabled by Bt Disable To trigger an instance by software use Bt Trigger After operation Bt DeInit can be used to de initialize a BT instance and disable its interrupts For each BT mode callback functions are provided for the following events e Callback0 Timer start trigger detection for PWM PPG RLT Completion of measurement for PWC e Callback1 Underflow detection for PWM PPG RLT Overflow detection for PWC e Callback2 Duty cycle detection for PWM Attention If an interrupt reason is enabled by the configuration the corresponding callback function pointer must be defined The BT ISR does not check the callback pointer for definition because of speed reasons The BT I O selector is configured by Bt InitIoSel The parameters are the BT instance pair 0 1 2 3 4 5 or 6 7 and the mode Bt TriggerInstances trigger bit pattern selected BT
284. structures If the sub clock was not enabled before the sub clock enable and stablilization is done in this function Prototype sia mese u Me Malic volatile See wea ic josieciic SBS wwe Comba TES pstecontig boolean t bTouchNvic Parameter Name Description in pstcWc WC instance pointer in pstcConfig Pointer to WC configuration in bTouchNvic TRUE Init NVIC registers FALSE Do not touch the NVIC registers Return Values Description Ok WC was set up successfully ErrorlInvalidParameter pstcWc NULL pstcWcInternData NULL Instance could not be resolved Wrong setting used ErrorInvalidMode Sub clock cannot be enabled or not existing 5 27 4 Wc Delnit De initializes the WC MCU AN 300412 E V14 250 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype em result t WE Deimit volatile gte ven festene boolean t bTouchNvic Parameter Name Description in pstcWc WC instance pointer in bTouchNvic TRUE Reset NVIC registers FALSE Do not touch the NVIC registers Return Values Description Ok WC was de initialized successfully ErrorlInvalidParameter pstcWc NULL pstcWcInternData NULL Instance could not be resolved 5 27 5 Wc GetTime This function calculates the time and date based on the UNIX T
285. t Ee WithCRLF FALSE LF is sent as itis 5 20 3 2 Lin Mode The configuration structure of the type of stc mfs lin t for Lin mode is Type Field Possible Values Description LinMaster Lin Master Mode pe Lin Slave Mode i TRUE External Wake up function bool s bExtWakeU gore DU TALSE No external Wake up Gimes E u32DataRate Bits per Second m LinOneStopBit 1 Stop Bit used Eu bxc enLin LinTwoStopBits 2 Stop Bits used uL a StopBits LinThreeStopBits 3 Stop Bits used LinFourStopBits 4 Stop Bits used Z E T LinBreakLength13 Lin Break 13 bit times Lin Master Fd LinBreakLength14 Lin Break 14 bit times Lin Master break Break a H dis e cm D LinBreakLength15 Lin Break 15 bit times Lin Master i LinBreakLength16 Lin Break 16 bit times Lin Master li inDelimiterLengthl Lin Break to Filed delimiter 1 bit time IA Sv inDelimiterLength2 Lin Break to Filed delimiter 2 bit times gelimiter_ RE Lin Break to Filed delimiter 3 bit times T th e SE SE length t eng inDelimiterLength4 Lin Break to Filed delimiter 4 bit times bLin n is TRUE Enable Break interrupt callback FALSE Disable Break interrupt callback Enable pebiai ee char E Pointer to transmission buffer Buffer ul6LinTx wimnele TE Buffer Length of transmission buffer Size ES pcLinRx E char t e Pointer to reception
286. t 12CWrite or s i2c datadirection t I2CRead X en mr m E SE s I2C SetNoiseFilter sets the MFS s noise filter if supported by the device type M For using MFS s LIN Mode use ws function with Mfs Lin prefix in the name Except for Mfs Read and Mfs Write Also stc mfs lin config t has to be used as the MFS configuration instead of stc MES config t Mfs Lin Init is used to initialize an MFS instance to LIN mode with its dedicated LIN configuration stc mfs lin config t Mfs Lin SetBreak set the LIN Break in LIN Master mode The baud rate divisor not the rate itself can be adjusted by Mfs Lin SetNewBaudDivisor after measurement with a dedicated ICU in LIN Slave mode Note that the LIN functionality only works properly when the MFS is connected to a LIN transceiver which means that the SOT line as always read back by SIN input MCU AN 300412 E V14 154 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Mfs Lin DisableRxInterrupt is used to disable the Rx interrupt if a LIN frame was completely read and a new frame beginning with the LIN break is awaited to avoid unnecessary reception of a 0 Byte with a framing error Mfs Lin TransferRxBuffer transfers the reception data from the internal ring buffer to a user buffer This function can be used for LIN Master and Slave mode becau
287. t ErrorlInvalidParameter pstcDt NULL e Illegal divider setting Fujitsu Semiconductor Europe GmbH 5 MCU AN 300412 E V14 Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 5 4 CIk SetStabilizationWaitTimes This function sets the stabilization wait times Prototype sn zes ile v Cilk Een names Ste Clk Contig tc psceComelg Parameter Name Description in pstcConfig Clock configuration parameters Return Values Description Ok Stabilization wait times have been set ErrorlInvalidParameter pstcConfig NULL ErrorInvalidMode O SEEDS MUGG legal timing setting 5 5 5 CIk WaitForMainOscillator This function waits for the Main Oscillator stabilization via polling 13 WAIT LOOP HOOK is called during polling It should be called if the system needs a stable main clock i e for communication or switching to PLL clock etc Prototype en resule t Cilk Ree or unto US Mame QuE Parameter Name Description in u32MaxTimeOut Time out counter start value Return Values Description Ok Main Clock stabilized ErrorTimeout Main Clock not stabilized after timeout count 5 5 6 CIk WaitForSubOscillator This function waits for the Sub Oscillator stabilization via polling 13 WAIT LOOP HOOK is called during polling It should be called i
288. t au8AdcBufferCh0 BUFFE L3 ZERO STRUCT stcAdcConfig0 tcAdcConfig0 u32CannelSelect AD CH 0 1 Enable ANO for ADCO tcAdcConfig0 u32CannelSelect AD CH 1 1 Enable ANO for ADCO tcAdcConfig0 enConversionMode AdcModeScanConversion tcAdcConfig0 enResolution Adc8Bit tcAdcConfig0 pu8ChannelBufferPointer 0 au8AdcBufferCh0 tcAdcConfig0 pu8ChannelBufferPointer 1 au8AdcBufferChl tcAdcConfig0 ul6ChannelBufferCounter 0 Init buffer counter tcAdcConfig0 ul6ChannelBufferEndCount BUFFER8SIZE Set buffer end tcAdcConfig0 enUseInterruptsDma AdcInterrupts stcAdcConfig0 pfnCallback amp Adc Callback stcAdcConfig0 pfnErrorCallback amp Adc ErrorCallback S S S S S S S S S H Sampling Times 9 a spe c 3 eve les SE 25 nsycycle 37 cycles 925 ms stcAdcConfig0 u8SamplingTime 9 stcAdcConfig0 enSamplingTimeMultiplier AdcSamplingTimeMultiplier4 3 Jf Comparison cycles Divider 5 25 nS ee Ene SEH 125 ns 14 1750 ns overall comparison time TYPEO device stcAdcConfig0 u8ComparisonTimeDivider 5 if Ok Adc Init stc aden t amp ADCO amp stcAdcConfigO0 pstcAdcO stc adcn t amp ADCO Ade TriggerStart pstcAdc0 while 0 u8ConversionDone if Wait fom Finish 5 2 16 3 DMA Mode 12 Bit The following code shows how to use the ADC in DMA mode using 8 Bit conversion Note that the full 32 Bit FIFO data incl
289. t be valid The required timing settings for data rate are calculated automatically with respect to the current peripheral clock 0 All necessary parameter to configure a MES channel can be set with the Mfs Init pstcConfig parameter all other interfaces Mfs Read Mfs Write Mfs Purge andMfs SynchronousTransfer will only operate with data to be sent or received over the configured MFS channel Preconditions Peripheral Clock 0 must be configured before to correctly set data rate e For MFS asynchronous mode the peripheral clock must be at least 5 times faster than the data rate to ensure proper oversampling e The Application must configure corresponding MFS pins SIN SOT SCK according to requirements and settings of MFS instance MCU AN 300412 E V14 158 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype sm result Mics Imite Bee mesa E syseMms Const See MrS Comic ic TEE ter Parameter Name Description in pstcMfs Pointer to MFS instance in pstcConfig Pointer to MFS configuration structure Return Values Description Ok MEFS initialization successfully done ErrorlInvalidParameter pstcMfs NULL e pstcConfig NULL pstcMfsInternData NULL Instance could not be resolved pstcConfig gt pcTxBuffer NULL pstcConfig gt pcRxBuffer NULL O
290. t clock PCLK 8 ft lock t Ppg2Clock BEE SE PPG2 Up count clock PCLK 32 PPG2 Up count clock PCLK 64 en mft ppg clock t enPpg4Clock see above PPG4 Up count clock PCLK 2 MCU AN 300412 E V14 192 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU PPG4 Up count clock PCLK 8 PPG4 Up count clock PCLK 32 PPG4 Up count clock PCLK 64 bPpgo BIT E OM DOM ME M T ROEI Invert Polarity to high if PPGO is stopped 5 Yu FALSE No inversion of Polarity Polarity pee TRUE Invert Polarity to high if PPG2 is stopped boolean t TOVO TE Aa amy gh PE 5 3 FALSE No inversion of Polarity Polarity SE TRUE Invert Polarity to high if PPG4 is stopped boolean t Invert de bed OG dde X E FALSE No inversion of Polarity Polarity ze EE Enables PPGO interrupt E Pes TALSE Disables PPGO interrupt Enable Ee _ TRUE Enables PPG2 interrupt SE Pes TALSE Disables PPG2 interrupt Enable Mem Aart EE S TRUE Enables PPGA interrupt ED tera BS TALSE Disables PPG4 interrupt Enable O EE x TRUE Interrupt on PPLHO underflow gt MT SE TALSE Interrupt on PPLLO underflow ode P ND Er MN Duci Interrupt on PPLH2 underflow 220 pam osa Interrupt on PPLL2
291. t or ongoing ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved e ul6WriteCount ErrorBufferFull Insufficient free size of TX buffer to take all data in case of bWait FALSE only 5 20 8 Mfs SynchronousTransfer This function will transmit and receive the same amount of data based on the serial shift clock signal MFS SCK pin in synchronous master or slave mode The operation mode of the MFS instance must be setup for synchronous master or slave mode While the data in M s SynchronousTransfer pu8TxData is transmitted the input data is received and stored in Mfs SynchronousTransfer pu8RxData The function operates in synchronous blocking mode only i e it will wait until the amount of data defined by Mfs SynchronousTransfer u8TransferSize is transmitted received No MFS internal buffers or transfer counters are used The Tx Rx callback functions will not be called Note that in synchronous slave mode the transfer is controlled by the external master device providing the serial shift clock This may cause this function to block very long time Because this function uses blocking method no interrupts are needed and therefore are not used Also no FIFO operation is performed Note Asynchronous non blocking Tx Rx operations are provided by using the functions Mfs Write and Mfs Read for MFS synchronous master and sla
292. tage eae o AdcPrioIrgFifoLevel3 IRQ request when result in 34 FIFO stage level t IrgLevel AdcPrioIrgFifoLevel4 IRO reguest when result in 4 FIFO stage u8PrioLevell PNE S o n 0 7 Priority level 1 analog input selection Channel channel u8PrioLevel2 Poa aita E oc ced 0 31 Priority level 2 analog input selection Channel channel bComparison TRUE Enables comparison function boolean t ES T 3 Enable FALSE Disables comparison function DOTEM bComparision TRUE IRQ if ADC value 2 CMPD GreaterEgual FALSE IRQ if ADC value lt CMPD bComparison TRUE Enables comparison channel boolean t Channel FALSE Disables comparison channel u8Comparison Defines channel of comparison if CG te Homel O so S enabled ul 6Comparison S uintl6 t EN Value of comparison tee u8Enable For device types 0 Enables cycle CycleValue setting Use 0xFF as default UNC MNO tara pfnCallback End of conversion callback pointer Fine ser pfnError Callback pointer for error during uL Callback conversion occurred A PENE FOR k D func ptr Se Priority scan callback pointer itio reae el i P Priority FIFO overrun error callback TME DEE Enrons sint CallbackAdc P MCU AN 300412 E V14 40 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 24 Adc_Init This function initializes an ADC instance according the given confi
293. tchdog shares its interrupt vector with the NMI Therefore use the stc wdg config t bTouchNVIC configuration whether to touch the NMI HWWdg NVIC registers or not Prototype en result t Wdg InitHwWdg stc wdg config t pstcConfig Parameter Name Description Hal psittcCont ig Pointer to Watchdog configuration structure Return Values Description Ok Setup sucessful ErrorInvalidParameter pstcConfig NULL 5 28 5 Wdg DisableHwWdg This function disables the Hardware Watchdog when the first argument is 0xC72E51A3 and the second agrument 0x89DB2E43 The magic words are together 64 bit wide and have a balanced entropy 32 zero and 32 one bits Prototype en result t Wdg DisableHwWdg stc wdg config t pstcConfig ames 18 u32MagicWordl k u32MagicWord2 Parameter Name Description in pstcConfig Pointer to Watchdog configuration structure in u32MagicWordl Must be 0xC72E51A3 in u32MagicWord2 Must be 0x8 9DB2E43 Return Values Description Ok Disable sucessful ErrorInvalidParameter Wrong magic word s provided Fujitsu Semiconductor Europe GmbH 255 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 28 6 Wdg FeedHwWdg This function feeds the Hardware Watchdog with the unlock feed and lock sequence
294. te This function must only be called if the recent MFS instance was initialized to Lin master or slave mode Otherwise the behavior of this function is undefined MCU AN 300412 E V14 172 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype Sin Sse te Mre bim Mesas dre STE CSTN SSM Eher ic pcData uintl6 t ul6ReadCount Parameter Name Description in pstcMfs Pointer to MFS instance in pcData Pointer to user reception buffer in ul6ReadCount Number of bytes to be transferred to reception buffer Return Values Description Ok Data was successfully transferred ErrorInvalidParameter psteMfs NULL 5 20 27 Mrs Lin DisableRxlnterrupt This function disables the reception interrupt Note This function must only be called if the recent MFS instance was initialized to Lin master or slave mode Otherwise the behavior of this function is undefined Prototype void Mrs lan DasableRxInterrupt ste msn t psteMfs Parameter Name Description Pointer to MFS instance not checked in this AR E function Return Values Description void 5 20 28 Mfs Lin Delnit This function just uses Mfs DeInit after checking LIN mode Prototype Sn restle e Mes Foto Detale Sto man CS CM Parameter Name Description in
295. ter Name Description in pstcCan CAN instance pointer in pstcConfig Pointer to CAN instance configuration Return Values Description Ok Initialization successfully done ErrorInvalidParameter pstcConfig NULL e pstcConfig NULL EE Ee EE mata NUL e pstcConfig gt stcBitrate u8TimeSegment1 out of range e pstcConfig gt stcBitrate u8TimeSegment2 out of range e pstcConfig gt stcBitrate u8SyncJumpWidth out of range e pstcConfig gt stcBitrate ul6Prescaler out of range e pstcConfig gt stcBitrate enCanPrescaler Wrong enumerator e pstcConfig gt stcBitrate enCanPrescaler CAN MAX CLK violated 5 4 3 Can_Delnit This function aborts any pending transmission and reception and all CAN related registers are reset to their default values Prototype enses utc C ame EEK VOTES tege annie OSTECEN A Parameter Name Description in pstcCan CAN instance pointer Return Values Description Ok De Initialization successfully done ErrorInvalidParameter pstcConfig NULL e pstcCanInternData NULL Invalid or deactivated CAN uint L3 PREIPHERAL ENABLE CANN 5 4 4 Can SetTransmitMsgBuffer Setting of new values is not possible if a transmission is pending except remote transmission mode The callback function p nCallback can be NULL but there will be no notification of a successful transmission This function has to be called at least once before function Can
296. ternal counting purposes only would oversize the configuration itself and the RAM consumption Mft PpgSwTrigger triggers selected PPG _ channels if configured to en mft ppg trigger t MftPpgTriggerRegister Mft PpgTimerStart starts PPG channels with the up counter delay synchronously if configured to en mft ppg trigger t MftPpgTimingGenerator Mft PpgTimerStop stops selected PPGs With Mft PpgSetValue8 Mft PpgSetValuel6 and Mft PpgSetValue8plus8 new pulse values can be set corresponding to the PPG mode defined in en mft ppg mode t Note that for generating PPG only signals bRt n HighLevel of stc mft frt ocu config t has to be set to TRUE Mft DeInit deinitializes an MFT instance Note that also here NULL pointers to not defined configurations cause no touch of the corresponding MFT parts On Tpye7 devices the following IGBT functions are also available Mft PpgIgbt Init Mft Ppglgbt Enable Mft PpglIgbt Disable Mft PpgIgbt DeInit Note To save configuration memory 16 16 bit mode is only available if the definition L3 PPG 1616 MODE AVAILABLE in 3 user h is set to L3 ON Caution This driver only supports Interrupt A ISR handling for MFT 5 21 1 Configuration Structures The MFT subresources uses the following configuration structures Fujitsu Semiconductor Europe GmbH 187 MCU AN 300412 E V
297. to the HS CR clock trimming register Prototype en result t Crtrim SetTrimmingFromFlash void Return Values Description Ok HS CR trimming has been setup ErrorInvalidParameter All trimming data bits are 1 Erased sector assumed 5 7 2 Crtrim SetTrimming This function copies the function s argument to the HS CR clock trimming register The maximum value CR TRIMM MAX VALUE is checked Device Type dependent Prototype em result e Crerim Seen lacio e ULET Denge Parameter Name Description iia din e Trimming data Return Values Description Ok HS CR trimming has been setup ErrorinvalidParameter Trimming data exceeds CR_TRIMM MAX VALUE MCU AN 3004 12 E V14 92 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 7 3 Crtrim UpdateFlash This function erases the CR trimming data sector and writes new data RAMCODE and FLASH code also if Work Flash is supported must be set active Prototype en result t Crtrim UpdateFlash uintl6 t ul6TrimmData Parameter Name Description iin to eo NE Trimming data Return Values Description Ok New HS CR trimming data has been written to Flash ErrorInvalidParameter Trimming data exceeds CR TRIMM MAX VALUE or Flash c
298. uint8 t u8Data u32BlockPage u32Block lt lt 5 u32Page Extif Nand SetCommand Extif Nand SetCommand EXTIF NAND ADDRESS 0x00 set programming area EXTIF NAND ADDRESS NAND CMD SEQIN write command Extif Nand SetAddress EXTIF NAND ADDRESS 0 Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage amp OxFF Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage gt gt 8 amp OxFF Possible further address cycles here Extif Nand ClearAle EXTIF NAND ADDRESS 1 1 1 1 for u32i 0 u32i lt 512 u32i Extif Nand WriteData EXTIF NAND ADDRESS pu8BufPtr write data for u32i 0 u32i lt 16 u321 Extif Nand WriteData EXTIF NAND ADDRESS au32Se u32i dummy write start programming Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD PAGEPROG if NAND FLASH ERROR Nand ReadStatus return NAND FLASH ERROR verify the write dat pu8BufPtr pu8Buf Extif Nand SetCommand EXTIF NAND ADDRESS NAND CMD READ0 read command Extif Nand SetAddress EXTIF NAND ADDRESS 0 Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage amp OxFF Extif Nand SetAddress EXTIF NAND ADDRESS u32BlockPage gt gt 8 amp OxFF Possible further address cycles here Extif Nand ClearAle EXTIF NAND ADDRESS Extif Wait 500 for u32i EE u8Data Extif Nan
299. ujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API au8TxBuffer 1 d Header no LIN meaning just test byte Set LIN Break for slave task Mfs Lin SetBreak pstcMfs Prepare LIN Master Reception Buffer complete frame Mfs Read pstcMfs char amp au8RxBuffer amp ul6ReadCount 4 FALSE u32CountRxCb 0 Write rest of slave task LIN Frame synch field and header Mfs Write pstcMfs char amp au8TxBuffer 2 FALSE Wait for all data read back field header and slave task while u32CountRxCb 4 5 20 35 6 LIN Slave communication The following code shows an example of LIN master communication It receives a master task Lin frame and then sends a slave task Lin frame Note that an external Lin transceiver is assumed which echoes every transmission Fujitsu Semiconductor Europe GmbH 183 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API include mfs h char cRxBuffer 8 Reception Ring Buffer char cTxBuffer 8 Transmission Ring Buffer uint32 t u32CountRxCb uint32 t u32LinBreak void Mfs4LbrCallback void u32LinBreak 1 void Mfs4RxCallback void u32CountRxCb function Steams min conmagut SECLE NCO EGAn MFS Lin configuration SCIES TEES pstcMfs NULL MFS instance L3 ZERO STRUCT stcLinConfig2 char au8RxBuffer 8 char au8TxBuffer
300. urce Driver API 5 5 CLK Clock Module Type Definition Configuration Type ste elk contig t Address Operator This driver manages the FM3 clock settings for e Clock Source Main Sub HS CR LS CR PLL e Clock Mode Run Sleep Timer Stop e Bus dividers HCLK PCLKO PCLK1 PCLK2 Stabilization Wait Times Main Sub PLL Also polling routines for the oscillation stabilization wait are provided e g Clk WaitForMainOscillator If this waiting polling is not wanted in the user application there are also function which return the current state of the stability of a clock e g Clk MainOscillatorReady For Clock Mode transition a hook function is called if specified for making individual power saving settings between setting SLEEPDEEP and the final wFI instruction Timer Sleep Stop modes Each wait function has at lest a parameter for time out counting The value of this parameter depends on the user s wait time settings Additionally these functions call the library s L3 WAIT LOOP HOOK function Notes After each Clock Source change Clk WaitForClockSourceReady with the clock source enumerator en clk source t and a time out count value as parameters has to be called if a previous waiting for stabilization was not performed e If the used device supports RTC and the RTC low power modes should be used switch L3 RTC AVAILABLE to L3_ON in 3_use
301. urn Values Description Ok Flash programming was successful ErrorTimeout Automatic programming algorithm timed out ErrorOperationInProgress Flash not ready to be programmed ErrorInvalidParameter Flash data cannot be programmed because one or more bits cannot be programmed from 0 to s L3 NO FLASH RAMCODE L3 ON and address not within Work Flash memory area Note this function is only able to re program a lower or upper byte of a 16 bit Flash memory word if the content equals to OxFF Otherwise an error is returned 5 16 3 Flash Write16 This function writes a 16 Bit word to the Flash memory If u32F1ashAddress is within the Work Flash memory area the corresponding ROM Flash routines are called if Work Flash is available and its area addressed The address u32FlashAddress must be 16 Bit aligned even address Prototype engesul te t Hash Wette unito ke us Fl shaddress adelen Parameter Name Description in u32FlashAddress Flash address in ul6Data 16 Bit Flash data to be programmed Return Values Description Ok Flash programming was successful ErrorTimeout Automatic programming algorithm timed out ErrorAddressAlignment u32FlashAddress not an even address ErrorOperationInProgress Flash not ready to be programmed ErrorInvalidParameter Flash data cannot be programmed because one or more bits cannot be programmed from 0 to Se L3 NO FLASH
302. usive channel number is transferred via DMA to the buffer For DMA usage refer to chapter 5 10 MCU AN 3004 12 E V14 46 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU include include define DMABUFF uint8 t u8Conversion Made dma h 16 ERSIZE Done 0 void Adc Callback void void Adc void Dma u8ConversionDone 1 ErrorCallback void Do something ErrorCallback uint8 t u8l Do something function stc dma config t S suetade conto Ae POACEAE uint32 t L S S S S S S S S S S S S UW Www o udo ou u ouo nu U W Uo U W U W S lt 3 7 ERO STRUC Setup ADC tcAdcConfigO Setup DMA tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcDmaConfig tcAdcConfigO tcAdcConfigO tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 tcAdcConfig0 ole sje bSoftwareTrigger bFixedSource bFixedDestination bReloadCount bReloadSource bReloadDestination 6 bCompletionInterruptEnable 519 pfnCallback stcDmaConfig pstcAdcO NULL stcAdcConfi
303. utionCount Recent Revolution Count Prototype void Oprc GetPositionRevolutionCount stc qprcn t pseegprer Stc qprc pos rev count t pstcPosRevCount Parameter Name Description in pstcQpre QPRC instance pointer Pointer to recent Position and Revolution Counter out values return structure as described above pstcPosRevCount 5 22 17 CountinversionCallback This function is called if stc gprc config t pfnCountInversionCallback is defined Callback Function void CountInversionCallback void Fujitsu Semiconductor Europe GmbH 223 MCU AN 3004 12 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 22 18 ZerolndexCallback This function is called if stc gprc config t pfnZeroIndexCallback is defined Callback Function void ZeroIndexCallback void 5 22 19 OverflowCallback This function is called if stc qprc config t pfnOverflowCallback is defined Callback Function void OverflowCallback void 5 22 20 UndeflowCallback This function is called if stc gprc config t pfnUnderflowCallback is defined Callback Function void UnderflowCallback void 5 22 21 RcMatchCallback This function is called if stc gprc config t pfnRcMatchCallback is defined Callback Function void RcMatchCallback void 5 22 22 PcMatchCallback This function is called i
304. vConfig bFcsIrqEnable tcCsvConfig bFcsIrqAutoClear tcCsvConfig enFcsCountCycle CsvFcsFreqDiv512 tcCsvConfig ul6FreqencyWindowLower CSV FCS LOWER tcCsvConfig ul6FreqencyWindowUpper CSV FCS UPPER tcCsvConfig pfnCallback amp CsvCallback In Q o odo uou WU Wu A Csv Init amp stcCsvConfig MCU AN 300412 E V14 98 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API 5 9 DAC Digital Analog Converter Type Definition SEG gem t Configuration Type z Address Operator DACn Because the DAC does not need any configuration no configuration structure and no Init or De Init functions are needed The output can be easily enabled and disabled by Dac Enable0 Dac Enablel Dac Disable0 and Dac Disablel The DAC value can be set by Dac SetValue0 and Dac SetValuel The indexes 0 and 1 correspond to the channel 0 and 1 of a DAC instance 5 9 1 Dac SetValueO Dac SetValue1 These functions set the 10 Bit DAC value to channel 0 or 1 Prototype en resulte t Dac ener geng Sue Caca ic PErCDEC uintl6 t ul6DacValue n 0 1 Parameter Name Description in pstcDac DAC instance pointer in ul6DacValue 10 Bit DAC value Return Values Description Ok DAC value set 5 9 2 Dac EnableO Dac Enable1 These functions enable a DAC channel Note that no other peripheral shal
305. values after initialization if needed The functions Oprc GetRevolutionCountCompare Oprc GetPositionRevolutionCountCompare and Qprc GetMaxPositionCount return the values of the corresponding registers Qprc DeInit should be called if the QPRC instance is no longer needed at runtime or a new configuration should be initialized afterwards Qprc GetPositionRevolutionCount can only be used on 2 Device Type 3 It reads out the Position and Revolution Count simultaneously and stores their values into a pointer structure Note The QPRC shares the interrupt vector with the Dual Timer Therefore stc qprc config t bTouchNVIC determines whether to touch the NVIC registers or not Take care that in the 2 case if the Dual Timer is used the NVIC initialization and de initialization must be handled by the Dual Timer driver 5 22 1 Configuration Structure The QPRC module uses the following channel configuration structure of the type SE stc qprc config t Possible TU Type Field Description yp Values p OprcPcMode0 Disable position counter en gprc DEMOS QprePcModel Increm AIN decrem BIN at active edges pcmode t OprcPcMode2 Phase different count mode OprcPcMode3 Directional count mode OprcRcMode0 Disable revolution counter en qpro e ET ce QprcRcModel Up Down count with ZIN active edge rcmode t OprcRcMode2 Up Down count on over underflow of PC OprcRcMode3 Up Down on over underf
306. ve modes too Note that these functions do not support full duplex operation Fujitsu Semiconductor Europe GmbH 161 MCU AN 300412 E V14 Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API Prototype SMS STK ie Mics VS O MOUSE AST SES mien c PSC S let ve pu8TxData WENES E pu8RxData Uta je u8TransferSize Parameter Name Description in pstcMfs Pointer to MFS instance in pu8TxData Pointer to transmission data buffer in pu8RxData Pointer to reception data buffer in u8TransferSize Number of transfers Must be gt 0 Return Values Description Ok Transmission data successfully sent or ongoing ErrorlInvalidParameter pstcMfs NULL pstcMfsInternData NULL Instance could not be resolved pu8TxData u8TransferSize ErrorOperationInProgress A transmission is still pending or the Rx buffer is not empty ErrorInvalidMode MFS module was not initialized in synchronous mode 5 20 9 Mfs PurgeRx The hardware reception FIFO and the software buffer are cleared Any data which is in the receive buffer at this time will be lost All settings done by Mfs Init will be preserved DMA operation for read will be disabled and read access to receive buffer by CPU will be enabled Prototype en result ic Mics Purge Gte mrem r PSLCMES Parameter Name Descr
307. veMsgBuffer the length for the mask identifier will be the same like the one used in pstcMsgBuffer 11 bit or 29 bit identifier mask The extended identification mask bit and the direction mask bit are always set to 1 The API has to check the bNew flag of parameter pstcMsgBuf fer to get information about if a message has already been received or not If a new message has been received while bNew flag is set the last received message was not read out by API so far than the bOverflow flag will be set So if callback function is not used the API has to reset the MCU AN 300412 E V14 66 Fujitsu Semiconductor Europe GmbH Low Level Library Manual FUJITSU Chapter 5 L3 Resource Driver API bNew flag when the received message is read out also the boverflow flag has to be reset and furthermore Prototype en result t Can SetReceiveMsgBuffer volatile stc cann t pstcCan Viste ne u8MsgBuf SIE euo mse ie pstcMsgBuffer iS e u32MsgIdMask can rx msg func ptr t pfnCallback Parameter Name Description in pstcCan CAN instance pointer in u8MsgBuf Message buffer index 0 CAN MESSAGE BUFFER COUNT 1 in pstcMsgBuffer Pointer to CAN message object which defines identifier for acceptance filter in u32MsgIdMask Mask for identifier acceptance filter and later receives the received message all 1 disables masking i
308. x 0 ul6Index lt DAC MAX DATA ul6Index f64Phi float64 t ul6Index f64Fract0 f64Sinus sin f64Phi aul6SinusO ul6Index uintl6 t float64 t 510 f64Sinus float64 t 512 f64Phi float64 t ul6Index f64Fractl f64Sinus sin f64Phi aul6Sinusl ul6Index uintl6 t float64 t 510 f64Sinus float64 t 512 Dac EnableO stc dacn t DACO Dac Enablel stc dacn t DACO Play sine wave tones while 1 for ul6Index 0 ul6Index lt DAC MAX DATA ul6Index Dac SetValuel stc dacn t DACO aul6SinusO ul6Index Dac SetValuel stc dacn t DACO aul6Sinusl ul6Index u32Delay 10 while u32Delay Fujitsu Semiconductor Europe GmbH 101 MCU AN 300412 E V14 FUJITSU Low Level Library Manual Chapter 5 L3 Resource Driver API 5 10 DMA Direct Memory Access The DMA is configured by Dma enables globally Once a DMA channel was setup by Dma the DMA Init Channel Type Definition Configuration Type ste dma config Address Operator Dma Disable but not started then With the function Dma Set Channel the enable pause and or trigger bits can be set Dma Enable and Dma DeInit Channel clears a channel for a possible new configuration disables DMA globally Init Channel it cannot be re initialized by this function with a new configuration anymore OperationInProgress is returned
309. y by the MFS implementation and will be changed according to the transmit and receive data length while any transmission or reception of data is ongoing Beside the Mfs Read and Mfs Write function it is possible to simulate a SPI transfer by using the function Mfs SynchronousTransfer The MFS has to be initialized in synchronous mode for using Mfs SynchronousTransfer To change the mode of MFS synchronous to asynchronous and vice versa or any other MFS connection related settings it will be necessary to call first M s DeInit to reset all MFS related register and to call Mfs Init afterwards with new mode and settings Any ongoing or pending transmission or reception will be cancelled and any data in the hardware FIFOs and ring buffer will be lost The API can call M s Purge to interrupt an ongoing transmission or reception without changing the MFS mode and settings All transmission and reception related buffer will be reset and all data in the buffer will be lost If the MFS module is used in synchronous receive and or transmit mode stc mfs config t pfnTxCallback and or stc mfs config t pfnRxCallback are NULL then the corresponding read and write functions Mfs Read Mfs Write and Mfs SynchronousTransfer have to be called with parameter bWait set to TRUE Note that this meaning of synchronous or asynchronous API handling is not the same like MFS synchronous or asynchronous data transfer The MFS module uses the re
310. y in your application to clear possible return cause bits Entering deep standby modes will not work correctly if cause bits are remaining Caution Consider that WKUPO pin is always active low level for DS modes so that it has to be pulled up by internal or external resistor Refer to the pin assignment of your device for setting corresponding PCR pull up register 5 11 1 Configuration Structure The DSM module uses the following channel configuration structure of the type stc dsm config t Type Field Possible Description Values DeepStop Deep Standby Stop mode EE P DeepRtc Deep Standby RTC mode boolean t bLpmPortHiZState SEN GE DARTE S HDMI CEC clocked by Sub Clock boolean t bSubClkHdmiCec FALSE HDMI CEC not clocked by Sub Clk TRUE RTC clocked by Sub Clock P Se FALSE RTC not clocked by Sub Clock boolean r bInitxResetReturn Ee Ge ee SC M boolean t bLvdResetReturn D o DR Reset 2 i TRUE Return from DSM by LVD IRQ boolean t bLvdInterrupt FALSE No return by LVD IRQ boolean t bRtcInterrupt ut ETC a IRQ uint8 t HdmiChannelEnable see below Defines return channel of HDMI MCU AN 300412 E V14 106 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU Stc hdmi channel t stcHdmiChannelEnable CEC remote control TSM E Wk
311. ypes 13 h file the macro definitions for TRUE FALSE MIN X Y MAX X Y etc are done This file should not be changed by the user 4 1 1 Type Definitions Additional types such as boolean t float32 t etc are done additionally to the CMSIS types 4 1 2 L3 Return Value Type en result t In the base types 3 h file the L3 global return or result enumeration is done For all L3 functions which have a return value which is not a certain value e g read value or status number this type shall be used Example of the result enumeration type definition generic error codes typedef enum en result Ok Error ErrorAddressAlignment ErrorAccessRights ErrorInvalidParameter ErrorOperationInProgress ErrorInvalidMode ErrorUninitialized ErrorBufferFull en eebe AE No error Non specific error code Address alignment does not match Wrong mode e g user system mode is set Provided parameter is not valid A conflicting or reguested op is still in progress Operation not allowed in current mode Module or part of it was not initialized properly Circular buf cannot be written cur buf is full r r r 0 1 2 3 4 5 7 8 4 2 File I3 c This file contains all global helper functions Recently only a hook function is provided which is called in any polling loop and can be used for setting user actions such as feeding a watchdog ckckckck kck AKA ck KA KA A K A A
312. zation successfully done 5 3 4 Bt_Enable This function enables a BT instance Bt_Init has to be called before Prototype SMS STU ic e EMAS ste SN SSB Parameter Name Description linl Sie c Bib BT instance pointer Return Values Description Ok BT instance successfully enabled 5 3 5 Bt Disable This function disables a BT instance Prototype SME STU EB Diselblel ste lom ic estere Parameter Name Description in pstcBt BT instance pointer Return Values Description Ok BT instance successfully disabled MCU AN 300412 E V14 52 Fujitsu Semiconductor Europe GmbH Low Level Library Manual Chapter 5 L3 Resource Driver API FUJITSU 5 3 6 Bt Trigger This function triggers a BT instance by software This function has no effect if the instance is configured as PWC Prototype em result v Be Trigger SCO SEO SSB 6 Parameter Name Description in pstcBt BT instance pointer Return Values Description Ok BT instance successfully triggered PWC mode is not checked 5 3 7 Bt ResetloSel This function resets all Base Timer s I O Selectors Prototype en result t Bt ResetIoSel void Return Values Description Ok All UO Selectors successfully reset to initial values 0 5 3 8 Bt InitloSel

Download Pdf Manuals

image

Related Search

Related Contents

ロ ELPA 取扱説明書  取扱説明書  OPERATOR`S MANUAL MANUEL de L  Descargar - Notifier by Honeywell  P3 International Glowstone P7400 User's Manual  RI2084 - Angeloni  SCA031U サイドカメラ接続アダプター  

Copyright © All rights reserved.
Failed to retrieve file