Jeśli nie używam poleceń "start tcc4 i stop tcc4 " to wszystko chodzi poprawnie .
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $REGFILE = "XM32E5DEF.DAT"
- $CRYSTAL = 50000000 '50MHz
- $HWSTACK = 200
- $SWSTACK = 200
- $FRAMESIZE = 200
- $LIB "XMEGA.LIB"
- ENABLE INTERRUPTS
- '----------------------------------------------------------------------------------------------
- ' CONFIG OSC = ENABLED , PLLOSC = ENABLED , PLLMUL = 29
- ' CONFIG SYSCLOCK = PLL
- '----------------------------------------------------------------------------------------------
- CONFIG OSC = ENABLED , EXTOSC = ENABLED , PLLOSC = ENABLED , _
- RANGE = 9MHZ_12MHZ , STARTUP = XTAL_16KCLK , PLLSOURCE = EXTCLOCK , PLLMUL = 5
- CONFIG SYSCLOCK = PLL , PRESCALEA = 1 , PRESCALEBC = 1_1
- '----------------------------------------------------------------------------------------------
- CONFIG PRIORITY = STATIC , VECTOR = APPLICATION , HI = ENABLED , MED = ENABLED , LO = ENABLED
- '*********************************************************************************************************************************
- '*** UART-COM3 *******************************************************************************************************************
- '*********************************************************************************************************************************
- CONFIG COM1 = 115200 , MODE = ASYNCHRONEOUS , PARITY = NONE , STOPBITS = 1 , DATABITS = 8
- OPEN "COM1:" FOR BINARY AS #1
- CONFIG SERIALIN = BUFFERED , SIZE = 30 , BYTEMATCH = 13
- ENABLE USARTc0_RXC, LO
- '---------------------------------
- DIM UART1 AS STRING*20
- DIM COM_1 AS WORD
- '
- '*********************************************************************************************************************************
- '*** TWIc ************************************************************************************************************************
- '*********************************************************************************************************************************
- '
- CONFIG SCL = PortC.1
- CONFIG SDA = PortC.0
- SET PortC.0
- SET PortC.1
- DIM TWI_START AS BYTE
- CONFIG TWIc = 400000
- OPEN "TWIc" FOR BINARY AS #4
- I2CINIT #4
- '
- '*********************************************************************************************************************************
- '*** LCD SSD1306 *****************************************************************************************************************
- '*********************************************************************************************************************************
- '
- $LIB "glcdSSD1306-I2C.lib"
- CONFIG GRAPHLCD = CUSTOM , COLS = 128 , ROWS = 64 , LCDNAME = "SSD1306"
- SETFONT Font8x8tt
- CLS
- '
- '*********************************************************************************************************************************
- '*** TCC4_OVF ********************************************************************************************************************
- '*********************************************************************************************************************************
- '
- CONFIG TCC4 = NORMAL , PRESCALE = 1 ' 1 , 2, 4, 8, 64, 256, 1024
- TCC4_PER = 65535
- ON TCC4_OVF PRZERWANIE_TCC4
- ENABLE TCC4_OVF , LO
- START TCC4
- '
- '*********************************************************************************************************************************
- '*** ZMIENNE *********************************************************************************************************************
- '*********************************************************************************************************************************
- '
- DIM TIK AS DWORD
- DIM LICZ AS INTEGER
- DIM WYNIK AS LONG
- DO
- TCC4_CNT=0
- 'START TCC4 - start i stop odhaczone i zlicza poprawnie
- WAITMS 1
- 'STOP TCC4
- WYNIK=TCC4_CNT
- LCDAT 1 , 10 , "CNT -";TCC4_CNT;" "
- LCDAT 2 , 10 , "WYNIK -";WYNIK;" "
- LCDAT 5 , 10 , "TIK -";TIK;" "
- LCDAT 6 , 10 , "LICZ -";LICZ;" "
- INCR TIK
- LOOP
- END
- '
- '-----------------------------------------------
- '
- SERIAL0CHARMATCH:
- PUSHALL
- INPUT #1, UART1 NOECHO
- COM_1=VAL(UART1)
- POPALL
- RETURN
- '
- '-----------------------------------------------
- $INCLUDE "font8x8TT.font"
- '-----------------------------------------------
- '
- PRZERWANIE_TCC4:
- INCR LICZ
- TCC4_INTflags.0=1
- RETURN
Przy zwykłych amegach lub xmega serii A to wszystko chodzi poprawnie . Fakt że te timery rodzaju 4 i 5 w xmega serii E są inne i pewnie tu jest "pies pogrzebany" .
Zna ktoś odpowiedź co jest nie tak .