Panowie potrzebuję 3 encoderów obsługiwanych przez xmega256a3u.
I sprawa ma się tak, uruchomiłem jeden - przykład zaczerpnięty z tego działu no i działa wyśmienicie,
ale potrzebuję jeszcze dwa encodery i najlepiej na jednym porcie.D
Jest coś tam wspomniane o indeksie, ale jak to ugryźć?
Poniżej mój kawałek kodu do rozbudowy o kolejne dwa enkodery, bardzo proszę o pomoc w tej sprawie.
- '*******************************************************************************
- 'Programm for Display ILI9325C SPI 240x320 Pixel
- '*******************************************************************************
- $regfile = "xm256a3udef.dat"
- $crystal = 32000000
- $hwstack = 512
- $swstack = 512
- $framesize = 512
- $lib "xmega.lib" : $external _xmegafix_clear : $external _xmegafix_rol_r1014
- Config Osc = Enabled , 32mhzosc = Enabled , 32khzosc = Enabled
- Bitwait Osc_status.1 , Set 'Check if 32MHz Oscillator is ready
- Bitwait Osc_status.2 , Set 'Check if internal 32.768 KHz Oscillator is ready
- Osc_dfllctrl = &B00000000 'The internal 32.768 KHz Oscillator is used for calibration
- Set Dfllrc32m_ctrl.0 'Enable DFLL and autocalibration
- Osc_pllctrl = &B10_0_01000 ' 32MHz clock Source and Multiplication factor = 16
- Set Osc_ctrl.4 ' PLL enable
- Bitwait Osc_status.4 , Set 'Check if PLL is ready
- Config Sysclock = Pll , Prescalea = 1 , Prescalebc = 1_2 ' configure the systemclock ---> use PLL
- Waitms 2
- Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
- Rem ******************************** CPU NORMAL 32MHz ******************************
- 'Config Clock = Soft , Rtc = 1khz_int32khz_ulp , Gosub = Sectic
- '$noramclear
- Rem ******************************** USTAWIENIA PINÓW ENCODERÓW ********************
- Config Pind.5 = Input ' przycisk impulsatora
- Config Pind.6 = Input ' przycisk impulsatora
- Config Pind.7 = Input ' przycisk impulsatora
- Config Pind.1 = Input 'enkoder 1B
- Config Pind.0 = Input 'enkoder 1A
- Config Pind.3 = Input ' enkoder 2B
- Config Pind.2 = Input ' enkoder 2A
- Config Pind.5 = Input ' enkoder 3B
- Config Pind.4 = Input ' enkoder 3A
- Config Xpin = Portd.1 , Outpull = Pullup , Sense = Low_level 'enable Pull up and reaction on low level
- Config Xpin = Portd.0 , Outpull = Pullup , Sense = Low_level
- Config Event_system = Dummy , Mux0 = Portd.0 , Qd0 = Enabled , Digflt0 = 4
- Config Tcd0 = Normal , Prescale = E0 , Event_source = E0 , Event_action = Qdec
- Rem ************************* Liczniki 16bitowe *******************************
- Config Tcc0 = Normal , Prescale = 1024
- Tcc0_per = 31250 '32MHz/1024 = 31250 --> One Second Tick
- On Tcc0_ovf Tc0_isr 'Nosave
- Enable Tcc0_ovf , Lo
- Rem Timer E0 16Bit
- Config Tce1 = Normal , Prescale = 1024
- Tce1_per = 31250 '32MHz/1024 = 31250 --> One Second Tick
- On Tce1_ovf Sekundnik 'Setup overflow interrupt of Timer/Counter E1 and name ISR
- Enable Tce1_ovf , Lo
- Config Eeprom = Mapped
- Enable Interrupts