Intermediate
20 min

Achieve high-quality scanning and printing results with TSL3301CL and STM32F302VC

Affordable excellence in scanning and printing

Scanner Click with CLICKER 4 for STM32F302VCT6

Published Jul 22, 2025

Click board™

Scanner Click

Dev. board

CLICKER 4 for STM32F302VCT6

Compiler

NECTO Studio

MCU

STM32F302VC

Make scanning and printing a breeze with our user-friendly optical scanning solution, delivering precise results for all your needs.

A

A

Hardware Overview

How does it work?

Scanner Click is based on the TSL3301CL, 102 × 1 linear optical sensor array with onboard A/D conversion from ams OSRAM. The sensor consists of 102 photodiodes, also called pixels, arranged in a linear array. Light energy impinging on a pixel generates a photocurrent, which is then integrated by the active integration circuitry associated with that pixel. During the integration period, a sampling capacitor connects to the output of the integrator through an analog switch. The amount of charge accumulated at each pixel is directly proportional to the light intensity on that pixel and to the integration time. Integration, sampling, output, and reset of the integrators are performed by the control logic in response to commands input via the SDI serial data input pin on the mikroBUS™. Data is then read out on the SDO serial data output pin. A normal sequence of operation consists of a pixel reset, start of integration, integration period, sampling of integrators, and pixel output. Reset sets all the integrators to zero.

Start of integration releases the integrators from the reset state and defines the beginning of the integration period. Sampling the integrators ends the integration period and stores the charge accumulated in each pixel in a sample and hold circuit. Reading the pixels causes the sampled value of each pixel to be converted to 8-bit digital format and output on the SDO serial data output pin. All 102 pixels are output sequentially unless interrupted by an abort command or reset command. Gain adjustment is controlled by three 5-bit DACs, one for each of the the three zones, while offset correction is controlled by three 8-bit sign-magnitude DACs and is performed in the analog domain prior to the digital conversion. There is a separate offset DAC for each of the three zones, where codes 0h - 7Fh correspond to positive offset values and codes 80h – FFh correspond to negative offset values. The programmed offset correction is applied to the sampled energy, and then the gain is applied (i.e. the gain will affect the offset correction). This Click board™

communicates over a serial digital interface (SPI serial interface) that follows a USART format, with start bit, 8 data bits, and one or more stop bits. Data is clocked in synchronously on the rising edge of system clock from SCK pin on the mikroBUS™ and clocked out on the falling edge of system clock. When clocking data out continuously (i.e. reading out pixels) there will be one stop bit between data words. The receive and transmit state machines are independent, which means commands can be issued while reading data. This feature allows starting new integration cycles while reading data. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Scanner hardware overview image

Features overview

Development board

Clicker 4 for STM32F3 is a compact development board designed as a complete solution, you can use it to quickly build your own gadgets with unique functionalities. Featuring a STM32F302VCT6, four mikroBUS™ sockets for Click boards™ connectivity, power managment, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core, there is a STM32F302VCT6 MCU, a powerful microcontroller by STMicroelectronics, based on the high-

performance Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the development

board much simpler and thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution which can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws. For most applications, a nice stylish casing is all that is needed to turn the Clicker 4 development board into a fully functional, custom design.

CLICKER 4 for STM32F302VCT6 double image

Microcontroller Overview

MCU Card / MCU

STM32F302VC Image

Architecture

ARM Cortex-M4

MCU Memory (KB)

256

Silicon Vendor

STMicroelectronics

Pin count

100

RAM (Bytes)

40960

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
SPI Clock
PA5
SCK
SPI Data OUT
PA6
MISO
SPI Data IN
PA7
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Scanner Click Schematic schematic

Step by step

Project assembly

PIC32MZ MXS Data Capture Board front image hardware assembly

Start by selecting your development board and Click board™. Begin with the CLICKER 4 for STM32F302VCT6 as your development board.

PIC32MZ MXS Data Capture Board front image hardware assembly
Thermo 21 Click front image hardware assembly
Board mapper by product6 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
PIC32MZ MXS Data Capture Board NECTO MCU Selection Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto image step 11 hardware assembly

Software Support

Library Description

This library contains API for Scanner Click driver.

Key functions:

  • scanner_clock - Pulse function.

  • scanner_serial_write_reg - Write function.

  • scanner_read_pixel - Read pixels.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * \file 
 * \brief Scanner Click example
 * 
 * # Description
 * This example reads data from Scanner Clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and starts up the module.
 * 
 * ## Application Task  
 * Reads the array of 102 pixels and displays the results on the USB UART 
 * as frequently as possible.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "scanner.h"

// ------------------------------------------------------------------ VARIABLES

static scanner_t scanner;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    scanner_cfg_t cfg;

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, "--->>> APP INIT <<<---\r\n" );

    //  Click initialization.

    scanner_cfg_setup( &cfg );
    SCANNER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    scanner_init( &scanner, &cfg );

    Delay_ms ( 300 );

    scanner_startup( &scanner );
    Delay_ms ( 100 );
    
    scanner_serial_write_reg( &scanner, SCANNER_REG_MODE, SCANNER_DATA_NORMAL_MODE );
    
    for ( uint8_t data_cnt = 0; data_cnt < 3; )
    {
        scanner_serial_write_reg( &scanner, SCANNER_REG_OFFSET_LEFT + ( 2 * data_cnt ), 25 );
        data_cnt++;
        scanner_serial_write_reg( &scanner, SCANNER_REG_GAIN_LEFT + ( 2 * data_cnt ), 25 );
        data_cnt++;
    }
    log_printf( &logger, "--->>> APP TASK <<<--- \r\n" );
}

void application_task ( void )
{
    uint8_t pixels[ 102 ];
    scanner_read_pixel( &scanner, pixels );
    
    log_printf( &logger, "left center right\r\n" );
    for ( uint8_t cnt = 0; cnt < 34; cnt++ )
    {
        log_printf( &logger, " %u   %u   %u \r\n", ( uint16_t ) pixels[ cnt ], 
                                                   ( uint16_t ) pixels[ cnt + 34 ], 
                                                   ( uint16_t ) pixels[ cnt + 68 ] );
    }
    log_printf( &logger, "----------------\r\n" );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.