Encore III CY8C64215 Analog column mux input

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

It has been several years since I last used the Encore III usb chip with the 14 bit ADC.  I recently put together an application on my raspberry pi, but in order to use the shiny new touch screen I got for it, I need to offload the sensor application from the onboard IO and since I had a few of these psoc chips on breakout boards in a box, I figured it would be appropriate to make a USB device.  Several years ago, Ganesh Raaja wrote a usb joystick example an illustrated how to configure the registers to use the analog bus and mux all the pins into an analog to digital converter.  I kept a copy of this and have used it for reference.  It centers on the ability to set up a unity gain pga and mux.  I had previously been able to edit the user module manifests in psoc designer so the encore III chip would effectively become the CY8C24894 chip and I could just drop in a PGA user module and not have to worry about all the registers from that example.  Since then, designer has gone through a few updates.  The question:  I'd like to use AnalogColumn_InputMUX_0 routed to the AnalogColumn_InputSelect_1 to AnalogColumnMuxBusSwitch_1 to ACB01 as a PGA unity gain amplifier routed to ASD11 as the positive input.  This will allow analog input from P0.1,P0.3, P0.5, P0.7 pins.  How do the registers need to be configured in the unity gain file to set this up correctly so I can use a mux user module to switch the pins?  The last time I tried to spoof psoc designer, it did not work.  Additinally I find it frustrating that there is no user module method to use the column muxes clearly available on the chips without having to custom configure the registers to push the signal to the only blocks that can be populated with analog inputs.  A lengthy study of the TRM for how to select the correct pins and get the correct references.  What a time waster and I'm sure I'm not the first to face this.  Any help would be appreciated.  I'll include the unity gain file referred to above to start the conversation:

   

 

   
    

#include <m8c.h>

    

unsigned char PGADefaults[5];
BYTE Setting;

    

/* This code for StartUnityGain from the original USB Gamepad Using Encore III draft 3 by Ganesh Raaja

    

// Originally called InitBuffer()

    

   // ACB00CR0
   // Bit 7-4: RTapMux - Gain of 1.000  (bits 7,6,5,4 - 0xF = 1111)
   // Bit 3: Set Gain bit  (bit 3 = 1)
   // Bit 2: Connect Rtop to Opamp's output  (bit 2 = 1)
   // Bit 1-0: Connect Rbot to Vss  (bits 1 and 0 = 10b)
    // register setting is 11111110b == 0xFE
   //ACB00CR0 = 0xFE;

    

   // ACB00CR1
   // Bit 7: Enable Analog Bus ( = 1)
   // Bit 6: Disable Comp Bus  ( = 0)
   // Bits 5-3: FB is Nmux input ( = 100)
   // Bits 2-0: Port Inputs is Pmux input ( = 111)
   //ACB00CR1 = 0xA1;

    

   // ACB00CR2
   // Bit  7: NA
   // Bit  6: NA
   // Bit  5: Disable Tmux 
   // Bits 3-2: NA
   // Bit  1-0: High Power
   //ACB00CR2 = 0x23;

    

   // ACB00CR3
   // Bit 3: Disable Low power comparator
   // Bit 2: Common mode output disabled
   // Bit 1: Normal Mode
   // Bit 0: Standard Gain Mode
   //ACB00CR3 = 0x00;

    

    // AMUX_CFG
    // Bit 7: BColMux1 -> input from "column muxes" or from analog mux bus (rt side = 0 = port pins, 1 = amux1)
    // Bit 6: BColMux0 -> input from left side is ( 0 = port 0 odd pins, 1 is amux0)
    // Bit 5-4: Int mux NA
    // Bit 3-1: Muxclk NA
    // Bit 0: ENable mux clock output...?
    //AMUX_CFG = 0x00;  &= with previous config for 0x20, 0x10, 0x08, 0x04, 0x02, 0x01     & 0X3F
  
  This implementation places the unity gain PGA in the ACB01 block.  
  Each original setting will first be stored in the PGADefaults[] array.

    

  */
void  StartUnityGain(void){
      PGADefaults[0] = ACB01CR0;        // Save the value before setting it
      ACB01CR0= 0xFE;                    // see comments above for settings
    PGADefaults[1] = ACB01CR1;        // Save the value before setting it
    ACB01CR1 = 0xA1;
    PGADefaults[2] = ACB01CR2;        // Save the value before setting it
       ACB01CR2 = 0x23;
    PGADefaults[3] = ACB01CR3;        // Save the value before setting it
       ACB01CR3 = 0x00;
    PGADefaults[4] = AMUX_CFG;
    Setting = PGADefaults[4] | 0x3F;
    AMUX_CFG = Setting;
}

    

/*
Stop Amplifier - Set Registers back to default... They were originally stored in PGADefaults[]
*/
void  StopUnityGain(void){
    ACB01CR0 = PGADefaults[0];
    ACB01CR1 = PGADefaults[1];
    ACB01CR2 = PGADefaults[2];
    ACB01CR3 = PGADefaults[3];
    AMUX_CFG = PGADefaults[4];
}
/*  Again, quoting from USB Gamepad Using Encore III draft 3 by Ganesh Raaja

    

"Analog Mux: The 64215 has two analog mux buses.  All the odd port bits like P0[1], P0[3], P0[5], P0[7], P1[1], P1[3] etc
connect to the left mux bus and all the even port bits like P0[0], P0[2], P0[4], P0[6], P1[0], P1[2] etc connect to the 
right mux bus.  There is an internal switch controlled by the SplitMux bit in the DAC_CR register that can connect 
these two mux buses.  When this bit is cleared, both the internal mux buses are connected thus forming a global mux 
bus that can connect any of the GPIO pin.  Setting this bit will split the mux bus into left and right buses.  
In our application, we will clear this bit so that we can acquire the analog inputs from any GPIO pin.
..
Each port pin has a single bit that controls the connection of the pin to the Mux bus.  
This bit is found in the MUX_CRx register.  For example, to connect P3[5] to the internal mux bus, 
Bit5 of MUX_CR3 register has to be set."

    

Bit seven must be set to 0 of the DAC_CR
To make sure only one input is connected at a time, all analog connections to the analog mux bus will be disconnected.

    

*/
void  StartAMUX(void){
    DAC_CR &= ~0x80;            // flip off bit 7 to enable a single mux bus
    MUX_CR0 = 0x00;                // disconnect any pins on port 0
    MUX_CR1 = 0x00;                // disconnect all pins on port 1
    MUX_CR2 = 0x00;                // disconnect all pins on port 2
}

    

/*
The stop port routine disconnects all pins from one port. 
Rather than do each pin individually, the entire port can be done in one write.
*/
void  StopPort(int Port){
    if(Port == 0){
        MUX_CR0 = 0x00;                // disconnect any pins on port 0
    }
    if(Port == 1){
        MUX_CR1 = 0x00;                // disconnect all pins on port 1
    }
    if(Port == 2){
        MUX_CR2 = 0x00;                // disconnect all pins on port 2
    }
}

    

/* toggle the mux bus setting to connect a specific port / pin
// This example uses port 0.  If port 1 is needed, change MUX_CR0 to MUX_CR1
// the pin numbers correspond with the hex bit placement to be turned on or off
// MAKE SURE THE MODE FOR EACH PIN IS SET CORRECTLY BEFORE USING IT AS ANALOG INPUT PIN!!
*/
void  SetChannel(int Port, int Pin){
    if(Port == 0){
        switch (Pin){
        case 0:
            MUX_CR0 = 0x01;                // all are off and pin 0 is on.
            break;
        case 1:
            MUX_CR0 = 0x02;
            break;
        case 2:
            MUX_CR0 = 0x04;
            break;
        case 3:
            MUX_CR0 = 0x08;
            break;
        case 4:
            MUX_CR0 = 0x10;
            break;
        case 5:
            MUX_CR0 = 0x20;
            break;
        case 6:
            MUX_CR0 = 0x40;
            break;
        case 7:
            MUX_CR0 = 0x80;
            break;
        }
    }
    if(Port == 1){
        switch (Pin){
        case 0:
            MUX_CR1 = 0x01;                // all are off and pin 0 is on.
            break;
        case 1:
            MUX_CR1 = 0x02;
            break;
        case 2:
            MUX_CR1 = 0x04;
            break;
        case 3:
            MUX_CR1 = 0x08;
            break;
        case 4:
            MUX_CR1 = 0x10;
            break;
        case 5:
            MUX_CR1 = 0x20;
            break;
        case 6:
            MUX_CR1 = 0x40;
            break;
        case 7:
            MUX_CR1 = 0x80;
            break;
        }
    }
    if(Port == 2){
        switch (Pin){
        case 0:
            MUX_CR2 = 0x01;                // all are off and pin 0 is on.
            break;
        case 1:
            MUX_CR2 = 0x02;
            break;
        case 2:
            MUX_CR2 = 0x04;
            break;
        case 3:
            MUX_CR2 = 0x08;
            break;
        case 4:
            MUX_CR2 = 0x10;
            break;
        case 5:
            MUX_CR2 = 0x20;
            break;
        case 6:
            MUX_CR2 = 0x40;
            break;
        case 7:
            MUX_CR2 = 0x80;
            break;
        }
    }
}

     
0 Likes
1 Reply
Anonymous
Not applicable

as  follow on, I copied the pga user module and edited it to allow the cy7c64215 devices to be listed on its manifest and imported it.  Its placement is not allowed in my device design.  Perhaps this edit might be a simpler approach than a custom register set.  I've not figured it out yet, but would be happy with perspective on either approach.

0 Likes