Microchip® Advanced Software Framework

twim_example.c File Reference

Example for TWIM driver implementation.

  • Compiler: IAR EWAVR32 and GNU GCC for AVR32
  • Supported devices: All AVR32 with TWIM controller.
  • AppNote:
Author
Microchip Technology Inc: http://www.microchip.com
/*****************************************************************************

Functions

static void init_sys_clocks (void)
 
static void twim_init (void)
 
int main (void)
 

Variables

uint8_t read_data [6]
 Array to store the received test data. More...
 
const uint8_t write_data []
 Array to store the test data for sending. More...
 
System Clock Frequencies

Information about Clock configuration and TWIM Module configuration

static scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false}
 
static pcl_freq_param_t pcl_freq_param
 

static void init_sys_clocks ( void  )
static
Remarks
The function will initialize the clocks.

References cpu_relax, PASS, pcl_configure_clocks(), and pcl_freq_param.

static void twim_init ( void  )
static
Remarks
TWI interface initialization

For UC3L devices, TWI default pins are, TWIMS0 -> PB05,PA21 TWIMS1 -> PB04 To enable TWI clock/data in another pin, these have to be assigned to other peripherals or as GPIO.

PIN 1 & 2 in Header J44 can be used in UC3L_EK

For UC3D devices, TWI default pins are, TWIMS -> PB09 (TWCK),PA10 (TWD) To enable TWI clock/data in another pin, these have to be assigned to other peripherals or as GPIO.

TWCK can be found on header PORTB.PB1 of the STK600 with RCUC3D TWD can be found on header PORTB.PB2 of the STK600 with RCUC3D

PIN 2 & 3 in Header J24 can be used in EVK1104 PIN 1 & 2 in Header J44 can be used in UC3C_EK

References FPBA_HZ, gpio_enable_gpio_pin(), gpio_enable_module(), print_dbg(), status, STATUS_OK, twi_options_t, and twim_master_init().

Referenced by main().

scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false}
static
pcl_freq_param_t pcl_freq_param
static
Initial value:
=
{
.main_clk_src = PCL_MC_DFLL0,
.cpu_f = FCPU_HZ,
.pba_f = FPBA_HZ,
.dfll_f = DFLL_FREQ_HZ,
.pextra_params = &gc_dfllif_ref_opt
}
#define DFLL_FREQ_HZ
Definition: twim_example.c:105
Definition: power_clocks_lib.h:106
#define FCPU_HZ
Definition: pevc_example3.c:89
#define FPBA_HZ
Definition: pevc_example3.c:90
static scif_gclk_opt_t gc_dfllif_ref_opt
Definition: twim_example.c:106
uint8_t read_data[6]

Array to store the received test data.

Referenced by main(), and sfh7770_calibrate().

const uint8_t write_data[]
Initial value:
= {
0xAA,
0x55,
0xA5,
0x5A,
0x77,
0x99
}

Array to store the test data for sending.

Referenced by flash_rw_example(), and main().