| [b6aa0ba] | 1 | Template EFM32JG1B, derived from previous EFM32 projects
|
|---|
| 2 | 20191213 Andreas Buchinger
|
|---|
| 3 | --------------------------------------------------------
|
|---|
| 4 |
|
|---|
| 5 | main.c, leds.c
|
|---|
| 6 | --------------
|
|---|
| 7 | RTC - set up to wake up core every ~1ms. Minimal scheduler for periodically
|
|---|
| 8 | 1ms, 10ms, 25ms... tasks. If all tasks are finished go to EM2.
|
|---|
| 9 |
|
|---|
| 10 | On STK3401A only 2 LEDs are mounted. Driven by GPIO [PF4] and PF5. PF4 is needed
|
|---|
| 11 | for Trace so only LED2 is used with STK3401A.
|
|---|
| 12 | [LED0 / PF4: Alive, switched on in main every second for 10ms]
|
|---|
| 13 | [LED1: Switched on during ADC conversion and during filtering (AdcFinishedIRQ)]
|
|---|
| 14 | LED2 / PF5: Shows when EFM is out of EM2 (EM1 JADE), switched on in every IRQ
|
|---|
| 15 | handler, switched off when entering EM2 (EM1 JADE)
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | TraceLeUart.c, Commands.c
|
|---|
| 19 | -------------------------
|
|---|
| 20 | PF3, PF4
|
|---|
| 21 | Minimal terminal functions via LEUART0 running in EM2 (before JADE). Debug
|
|---|
| 22 | message output. Routed to 10pin header pin 2/3 on Olimex board and at DEBUG
|
|---|
| 23 | connector on all own boards. 9600bps for older boards. Starting with JADE
|
|---|
| 24 | 115200bps, 1 stop, no parity, no handshake. JADE/PEARL (JG1B) does have
|
|---|
| 25 | terrible jitter on LFRCO so debug out does not work relialbe with more than
|
|---|
| 26 | 2400bps. So switching LEUART clock to HFRCO and using 115200bps. Drawback -
|
|---|
| 27 | switching to EM2 is not possible when debug data are sent out. This may
|
|---|
| 28 | significantly increase energy consumption depending on debug data.
|
|---|
| 29 |
|
|---|
| 30 | Debug messages are defined by simple use of TRACE(), TRACE_L2() and TRACE_L3()
|
|---|
| 31 | macros. Message format in printf style. \r\n is automatically added with every
|
|---|
| 32 | TRACE message. Debug level from 0 to 3 is defined in trace.h for every single
|
|---|
| 33 | module. Level 0 means no logging at all and NO ADDITIONAL CODE. It is not
|
|---|
| 34 | necessary to clean up sources for release builds but only set log level to 0 in
|
|---|
| 35 | trace.h (or uncomment NO_TRACE) and there is no code overhead anymore.
|
|---|
| 36 |
|
|---|
| 37 | Trace messages are copied into a ring buffer and sent out in background via
|
|---|
| 38 | LEUART0 IRQ handler (even in EM2 before JADE). Buffer copying and sprintf used
|
|---|
| 39 | with TRACE uses only little time but do have small influence on execution speed.
|
|---|
| 40 | If too much logging info is requested as with 9600bps can be sent out, buffer
|
|---|
| 41 | fills up and overflow may occure. *** is inserted in output stream in such cases
|
|---|
| 42 | and trace info is lost. For Ring buffer size see LOG_TX_RING_BUF_SIZE in
|
|---|
| 43 | TraceLeUart.c.
|
|---|
| 44 |
|
|---|
| 45 | !!! ARM Cortex-M3 Hard Fault Handler !!!
|
|---|
| 46 | tries to write readable fault information to debug out and restart system
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | Hardware.c
|
|---|
| 50 | ----------
|
|---|
| 51 | Hardware dependant functions. Version/Revision, UID, DIP-Switches, ...
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | Adc.c
|
|---|
| 55 | -----
|
|---|
| 56 | Starting with JADE ADC is configured to run in EM2 without any CPU
|
|---|
| 57 | intervention. LETIMER0 is used to trigger ADC via PRS and LDMA transfers
|
|---|
| 58 | results into adcBuffer. LETIMER0 runs at 1kHz. Every 1ms new ADC samples
|
|---|
| 59 | for all configured inputs (AdcInit) are transferd to the buffer.
|
|---|
| 60 | Based on github adc_scan_letimer_prs_dma sample
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | Used Ressources:
|
|---|
| 65 | ----------------
|
|---|
| 66 | main.c
|
|---|
| 67 | RTC ... system clock, wakes up every ~1ms, running from LFRCO
|
|---|
| 68 |
|
|---|
| 69 | TraceLeUart.c
|
|---|
| 70 | LEUART0 ... trace output with 115200bps routed at 10pin header
|
|---|
| 71 |
|
|---|
| 72 | Adc.c
|
|---|
| 73 | LETIMER0... triggers ADC every 1ms
|
|---|
| 74 |
|
|---|
| 75 | LDMA_CHANNEL 0
|
|---|
| 76 | PRS_CHANNEL 0
|
|---|
| 77 |
|
|---|
| 78 | IRQs Priority Modul
|
|---|
| 79 | RTC 7 main
|
|---|
| 80 | LEUART0 7 TraceLeUart
|
|---|
| 81 | GPIO_EVEN 7 TraceLeUart
|
|---|
| 82 | LDMA 6 Adc
|
|---|
| 83 |
|
|---|
| 84 | Valid priority values are 0..7 where 7 is the lowest priority. Default 0.
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|