CONFIG FT800

From MCS Wiki AVR
Revision as of 23:16, 15 June 2015 by Admin (Talk | contribs)
Jump to: navigation, search

Contents

 [hide

Action

This compiler option is required to setup the FT800 SPI interface.

 

 

Syntax

CONFIG FT800 = spi [, FTSAVE=ftsave , FTDEBUG=ftdebug] , FTCS=ftcs [, FTPD = ftpd] [,FTCHIP=800|801] [,PLATFORM=platform] [,LCD_SCREEN-lcdscr] [,LCD_ROTATE=lcdrotate] [,LCD_CALIBRATION=calib]

 

 

Remarks

 

spi

The SPI interface used for the FT800 processor. This may be :

- SPI, for normal AVR processors

- SPIC, SPID, SPIE, SPIF, for XMEGA processors.

ftsave

This is an optional parameter with a default of 0. The possible values are 0 and 1. With this option enabled, the parameters passed to the various FT800 routines are limited in range. For example when a parameter is expected in the range from 0-31 it would not matter if you pass 32. But limiting the range increases code. It is best to make sure yourself that you pass the proper values.

ftdebug

This is an optional parameter with a default of 0. The possible values are 0 and 1. With this option enabled, the SPI communication can be monitored. A label named _FTDBG is called in your code. So when using this option you need to insert this label into your code. You also need to DIM a byte namedftdebug. This byte will be filled with the parameter sent to the SPI.

Make sure you put a RETURN after the label and save registers you use:

 

_FTDBG

Pushall

print hex(ftdebug)

Popall

RETURN

FTCS

The name of the SPI port pin connected to the CS pin of the FT800. This would be SS in most cases. This pin is set to output and to logic level 1.

FTPD

The name of the port pin connected to the PD pin of the FT800. This is an optional pin, it depends on your hardware. Gameduino2 does not require it. EVE demo boards do require this pin.

 

The CONFIG FT800 statement will inform the compiler to use the FT800.LIB. It will also create an ALIAS for the CS and PD pins you specify.

The FT800 is controlled by the SPI interface. This means that you need to configure the SPI the usual way.

 

BASCOM FT800 support is implemented in the following way:

- a low level communication library FT800.LIB

- ASM include macros which are located in the FT800.LIB. Unlike sub routines, the code is included and not called.

- BASCOM high level commands such as CMD32, RD8(), RD16(), etc.

- FT800 include files : an include file with the declarations (FT800.INC) and an include file with the actual code (FT800_FUNCTIONS.INC).

 

You may modify the code from the include files. The code will reveal some new options. It is important to understand these new options.

- Passing values using BYREG

- Passing values using BYSTACK

CMDFTSTACK

 

 

 

 

See also

 , CMDFTSTACK , CMD32 , RD8RD16RD32 , WR32

 

 

 

Partial Example

' FT800 Gauges Application demonstrating interactive Gauges using Lines & Custom Font
' FT800 platform.
' Original code from http://www.ftdichip.com/Support/SoftwareExamples/EVE/FT_App_Gauges.zip
' Requires Bascom 2.0.7.8 or greater
 
$Regfile = "M328pdef.dat"
$Crystal = 8000000
$Baud = 19200
$HwStack = 90
$SwStack = 90
$FrameSize = 300
$NOTYPECHECK
 
Config ft800=spi , ftsave=0, ftdebug=0 , ftcs=portb.2, ftpd=portb.1
 
Config Base = 0
Config Submode = New
Config Spi = Hard , Interrupt = Off , Data_Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4, Noss = 1
SPSR = 1 ' Makes SPI run at 8Mhz instead of 4Mhz
 
 
' Swaps Scales
' 1 = Resitive - Random
' 0 = Random - Resistive
Const Resistive = 0
 
#If Resistive = 0
 Const First = 1
 Const Second = 0
#Else
 Const First = 0
 Const Second = 1
#EndIf
 
$Include "FT800.inc"
$Include "FT800_Functions.inc"
 
Declare Sub cs(Byval i As Byte)
Declare Function da (Byval i As Long) As Word
Declare Sub Polar(byval R As Long , Byval Th As Word)
Declare Sub Polarxy(byval R As Long , Byval Th As Word , Byref X As Long , Byref Y As Long)
Declare Sub IntroFTDI
Declare Sub Gauges
Declare Function Read_Keys() As Byte
 
' General Program Variables and Declarations
Dim temp_tag As Byte
Dim ox As Long
 
 
Spiinit
 
if FT800_Init()=1 then end ' Initialise the FT800
 
Gauges
 
Do
 
Loop

Remark

In the samples, Noss = 1 is used for CONFIG SPI. This means that the SS pin must be set by the user. In case of CONFIG FT800, the compiler always set the specified pin for FTCS to output and to logic 1. When possible you should use NOSS=0 and use the dedicated SPI SS pin. But for multiple SPI devices on the bus that is not possible since you will have multiple CS pins, and in these cases you should use NOSS=1, so you can control the SS logic level.


Languages   English  
Personal tools
Namespaces
Variants
Actions
Navigation
Language