RSS YouTube LinkedIn Twitter XCore IRC

Search

Projects Tutorials Forum

Personal tools

Programming Ports in XC

From XCore Exchange

Jump to: navigation, search

This page describes how to utilise ports and their features in XC along with simple worked examples.

Contents

Basic Port Use

Configuring Clocked Ports

Configuring Ports with Handshaking

Unorthodox port usage

This section handles things that are possible with ports that might be considered 'unorthodox'.

Outputting the inverted output of another 1 bit port

By utilising a clock block a developer is able to output the inverse of a 1 bit port on another 1 bit port without needing to write to the port (NOTE: this only works with 1 bit ports and will use 1 clock block).

This can be configured using the following code block:

void setup_inverted_port( out port p, out port p_inv, clock c )
{
   // set port p as the source for clock block c
   set_clock_src (c, p); 

   // set port p_inv to be attached to the clock block c
   set_port_clock (p_inv, c);

   // set port p_inv to output the clock block c
   set_port_mode_clock (p_inv);

   // start the clock block and therefore the inverted output
   start_clock( c );
}