firmware  v0.1.2
Chromation Spectrometer Dev-Kit
Macros | Typedefs | Functions | Variables
S13131.h File Reference
#include <stdint.h>
#include <ReadWriteBits.h>

Go to the source code of this file.

Macros

#define MAX_NUM_PIXELS   512
 S13131-512 has 512 pixels.
 

Typedefs

typedef uint8_t volatile *const s13131_ptr
 
typedef uint8_t const s13131_pin
 
typedef uint8_t const s13131_bit
 

Functions

uint8_t MSB (uint16_t msb_lsb)
 
uint8_t LSB (uint16_t msb_lsb)
 
void S13131PinSetup (void)
 
void S13131StartClocking (void)
 
void WaitForS13131ClkLow (void)
 
void WaitForS13131ClkHigh (void)
 
void S13131Expose (void)
 

Variables

uint16_t exposure_ticks
 S13131 exposure time. More...
 
s13131_ptr S13131_ddr
 
s13131_ptr S13131_port
 
s13131_ptr S13131_pin
 
s13131_ptr S13131_TCCR0A
 
s13131_ptr S13131_TCCR0B
 
s13131_ptr S13131_TIFR0
 
s13131_ptr S13131_OCR0A
 
s13131_ptr S13131_OCR0B
 
s13131_pin S13131_Clk
 
s13131_pin S13131_St
 
s13131_pin S13131_Eos
 
s13131_bit S13131_WGM00
 
s13131_bit S13131_WGM01
 
s13131_bit S13131_WGM02
 
s13131_bit S13131_CS00
 
s13131_bit S13131_CS01
 
s13131_bit S13131_CS02
 
s13131_bit S13131_COM0B0
 
s13131_bit S13131_COM0B1
 
s13131_bit S13131_OCF0A
 
s13131_bit S13131_OCF0B
 

Detailed Description

API

void S13131PinSetup(void);
void S13131StartClocking(void);
void S13131Expose(void);
S13131Readout is defined in VisCmd

Definition in file S13131.h.

Function Documentation

◆ LSB()

uint8_t LSB ( uint16_t  msb_lsb)
inline

LSB behavior:

  • returns least significant bit of 16bit input

Definition at line 38 of file S13131.h.

◆ MSB()

uint8_t MSB ( uint16_t  msb_lsb)
inline

MSB behavior:

  • returns most significant bit of 16bit input

Definition at line 31 of file S13131.h.

◆ S13131Expose()

void S13131Expose ( void  )
inline

Exposure signals:

  • ST idles LOW
  • ST goes HIGH to start exposure
    • Bring ST HIGH some time prior to a CLK rising edge (easiest is to bring ST HIGH just after a CLK falling edge)
    • Integration time officially starts on the 3rd CLK rising edge with ST HIGH
      • the time period from that 3rd rising edge to the 4th rising edge marks the first cycle of exposure time
  • ST goes LOW to end exposure
    • Bring ST LOW some time prior to a CLK rising edge (against, easiest is to do this just after a CLK falling edge)
    • Integration time officially stops on the 9th CLK rising edge with ST LOW

This implies that the minimum integration time is 9 clocks. At 50kHz, each clock is 20µs, so minimum integration time is 180µs.

Example: minimum exposure time

┌─── Count all rising edges of CLK starting with first ST HIGH
│ ┌─ Count rising edges of CLK where ST is LOW
↓ ↓
(x,y)
Exposure clocks -------> 1,0 2,0 3,0 4,1 5,2 6,3 7,4 8,5 9,6 10,7 11,8 12,9
┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐
CLK │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └
↑ ↑ ↑ ↑ ↑
ST HIGH clocked-in: ─┘ │ │ │ │
exposure START: ─┘ │ │ exposure STOP: ─┘
ST LOW clocked-in: ─┘ │ on 9th CLK rising-edge
│ with ST LOW
┌─────────────────┐ │
ST IDLE LOW │ │ ↓
──────────────────┘ └─────────────────────────────────────────────────────
↑ ↑
│ │
Wait for CLK LOW │ │
to pull ST HIGH: ─┘ │
Wait for CLK LOW │
to pull ST LOW: ─┘

Relationship between exposure and readout:

  • exposure ends on the 9th CLK rising edge with ST LOW
  • sample first pixel on the 14th CLK falling edge with ST LOW

Therefore, readout always starts 13.5 clocks after ST LOW.

Example: ST HIGH for 3 clocks (4 CLK rising edges)
This corresponds to an integration time of 10 clocks (200 µs)

Pixel count ---------------------------------------------------------------------------------------------------------------------> 001---002-││511---512---
┌──┌──┌──┌││┌──┌──┌──┌──
↓ │--│ ││││ │--│ │--
14th TRIG rising-edge (CLK falling-edge) with ST LOW: ────────────────────────────────────────────────────────────────────────────────┐ │--│ ││││ │--│ │--
First TRIG rising-edge (CLK falling-edge) with ST LOW: ─┐ │ │--│ ││││ │--│ │--
↓ ↓ │--│ ││││ │--│ │--
Clocks waiting for readout to start ---------------> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 │--│ ││││ │--│ │--
Exposure clocks --------> 1,0 2,0 3,0 4,0 5,1 6,2 7,3 8,4 9,5 10,6 11,7 12,8 13,9 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓││↓ ↓ ↓ ↓
┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌││┐ ┌──┐ ┌──
CLK │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ││││ │ │ │
──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘││└──┘ └──┘
↑ ↑ ↑ ↑ ↑
ST HIGH clocked-in: ─┘ │ │ │ │
exposure START: ─┘ │ │ exposure STOP: ─┘
ST LOW clocked-in: ─┘ │ on 9th CLK rising-edge
│ with ST LOW
┌───────────────────────┐ │
ST IDLE LOW │ │ ↓
──────────────────┘ └────────────────────────────────────────────────────────
↑ ↑
│ │
Wait for CLK LOW │ Wait for CLK LOW │
to pull ST HIGH: ─┘ to pull ST LOW: ─┘

Definition at line 191 of file S13131.h.

Variable Documentation

◆ exposure_ticks

uint16_t exposure_ticks
extern

S13131 exposure time.

  • exposure is a 16-bit word
  • exposure is in units of clock ticks
  • multiply exposure by 20e-6 seconds to get exposure time in seconds
    • one clock tick is 20e-6 seconds because the S13131 is clocked at 50kHz
  • minimum allowed exposure time is 180e-6 seconds (exposure_ticks = 9)
  • exposure_ticks is clamped at 9 ticks
    • exposure_ticks is set to 9 if SetExposure attempts a value < 9

S13131 exposure time.

  • exposure is a 16-bit word
  • exposure is in units of clock ticks
  • multiply exposure by 20e-6 seconds to get exposure time in seconds
    • one clock tick is 20e-6 seconds because the LIS-770i is clocked at 50kHz

Definition at line 32 of file Lis.c.