Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20688

BASCOM-AVR : HTRC110 with XMEGA : REPLY

$
0
0
I took a quick look at this NXP part, HTRC110 , it uses a SPI interface, so not sure why you need interrupts. Sounds like you need to re-read through the xmega documention about pin interrupts, since they are very comprehensive. Sorry I have no sw written for this part. NXP usually does a good job at docs, so look for app notes and example code for interfacing to this part. make sure SPI signal levels are compatible with the xmega supply V. Here is an example of setting up SPI on xmega,it uses a Bourns encoder as volume control for the PGA2310/11/20 part. I used the DAC as a ramp generator for the test signal. [code:1:d6f189ed25]'CONFIG SPI MASTER on Port C 'PGA2311: MSB first, clocked on rising edge,R7..R0,L7..L0 ' ' MOSI, PortC.5: Connect to PGA2311.3 (SDI) ' MISO, PortC.6: Not used ' SCK, PortC.7: Connect to PGA2311.6 (SCLK) ' CS, PortC.4: Connect to PGA2311.2 (~CS) Config Portc.4 = Output Pga_cs Alias Portc.4 Set Pga_cs 'Slave Select Pin, Connect to PGA2311-2 (CS), active low 'Dim Select_bit As Bit 'Portc_pin0ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge 'Portc_pin1ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge 'Portc_pin2ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge 'Portc_pin3ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge Portc_pin4ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge Portc_pin5ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge Portc_pin7ctrl = &B10_011_010 ' slew, no invert, Totempole, Pull-up (on input),Sense falling edge Config Spic = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk32 , Data_order = Msb , Ss = None 'Config Spic = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk64 , Data_order = Msb , Ss = None Open "SPIC" For Binary As #3[/code:1:d6f189ed25] below find the print call that is the SPI transfer [code:1:d6f189ed25] If Encoder2old <> Encoder2 Then 'Use for Volume/Balance Function If Pga2311_mute = 1 Then ' Volume_count = Encoder2 Encoder2old = 0 Encoder2 = 0 Volume = Volume + Volume_count 'Volume_L = Volume_L + Volume_count 'Volume_R = Volume_R + Volume_count Disable Interrupts Encoder2old = Encoder2 Enable Interrupts 'If Volume_L > 212 Then Volume = 212 'If Volume_R > 212 Then Volume = 212 If Volume > Volume_max Then Volume = Volume_max 'Volume Limit, max 255 If Volume < 0 Then Volume = 0 'If Volume_L < 0 Then Volume_L = 0 'If Volume_R < 0 Then Volume_R = 0 Volume_s = Volume Volume_s = 255 - Volume_s Volume_s = Volume_s / 2 Volume_s = 31.5 - Volume_s '31.5 -(0.5 *(255 - N)) ___lcde = 1 Locate 1 , 1 'Lcd "****************************************" Lcd "Volume L = " Locate 1 , 12 Lcd Fusing(volume_s , "#.#") ; " dB " Locate 1 , 21 Lcd "R = " Lcd Fusing(volume_s , "#.#") ; " dB" 'Dim Volume_word As Word 'Dim V_right As Byte At Volume_word Overlay 'Dim V_left As Byte At Volume_word + 1 Overlay V_right = Volume 'Assemble word for PGA2311 V_left = Volume 'Need to add balance function Reset Pga_cs 'Select SPI Slave Print #3 , Volume_word 'Send 16 bits to PGA2310 Set Pga_cs 'Deselect SPI Slave End If End If[/code:1:d6f189ed25] The encoder read in based on a counter overflow interrupt. Rick

Viewing all articles
Browse latest Browse all 20688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>