Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 35

Thread: Please Post Code & Details In Your Question!

  1. #1
    Administrator Paul's Avatar
    Join Date
    Oct 2012
    Posts
    444

    Please Post Code & Details In Your Question!

    Please, when asking a technical question, provide enough information for us to help!


    • Complete Source Code (or a link to the code)
    • Screenshot or the exact text of any error messages
    • Which PJRC product you're using
    • Part numbers of any other chips or modules + links to their info
    • Wiring details - how exactly have you connected the hardware (a photo's worth 1000 words)
    • Software setup, Arduino vs C+makefile, running on Windows, Mac or Linux?Versions?
    • Any other information needed to reproduce the problem.....


    Providing enough detailed information to reproduce your problem saves everyone time and greatly increases the odds we'll be able to help you with a useful answer.

    If you haven't connected wires or run code yet, please post your question in the Project Guidance forum.

  2. #2
    is there a way -tags or otherwise - to format attached code? If I copy and paste code in it is wrapping long lines and removing indention.

  3. #3
    Senior Member ZTiK.nl's Avatar
    Join Date
    Dec 2012
    Location
    Amsterdam
    Posts
    179
    use the [ CODE] and [ /CODE] tags for that.
    If you want to see all tags, click on the 'Go Advanced' button below the Quick Reply field :)

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,128
    Unfortunately the forum software hides the button that inserts code tags, unless you click 'Advanced'. Its the button that looks like this: #

    Click image for larger version. 

Name:	codetags.png 
Views:	1129 
Size:	17.3 KB 
ID:	240

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,973
    You can also attach the file. Click "go advanced" and then it's Manage Attachments below your message. Often when looking at someone's, I load it into vim, so I get familiar syntax highlighting. But the code tags work nicely for small bits of code.
    Last edited by PaulStoffregen; 03-01-2013 at 06:30 PM.

  6. #6
    Junior Member
    Join Date
    Aug 2014
    Posts
    5
    When I try to run the movie2serial program, it could not load the file. Im not sure if the path I wrote is in the correct format. The fp.avi and the movie2serial is in the same folder already.
    I've try both of this but none of them work.

    Movie myMovie = new Movie(this, "/tmp/fp.avi");
    Movie myMovie = new Movie(this, "fp.avi");

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,973
    Quote Originally Posted by yustinusa agung View Post
    i have question about Analog input ..
    You should start a new thread, in the project guidance section, to discuss this in more detail.

    can i read analog output 1-5 v with teensy 3.1
    The ADC pins are limited to 3.3V max measurement range. You'll need to use resistors or a circuit to reduce the signal to match Teensy's input range.

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    17,127
    Paul: Can the Forum page top rule be a hyper link to this page/post?

    https://forum.pjrc.com/threads/15136...ll=1#post17615

  9. #9
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,825
    I'd suggest that the DMA chaining scheme could interleave the bytes: 1st pass does half, second pass does others. But DMA hardware requires address aligned buffers.

  10. #10
    I am trying to merge two Audio Workshop tutorial sketches together to run the part 3-2 FFT1024 with the part 3-3 Add a TFT Display. I have a breadboard large enough to incorporate the (2.8 in ILI9341 display), audio board and Teensy 3.2 board. Of course, both tutorial sketches work fine by themselves. So I have attached the combined sketches as one file inwhich I commented out the bar drawing in 3-3 as I was just trying to print one of the FFT numbers (leftNumber) to start with instead of the peak1 or peak2 functions. The sketch compiles except at the end it gives the following error (region 'FLASH' overflow by 3768 bytes):

    Click image for larger version. 

Name:	Error Capture Part_3_02_Rourier_Transform_Mod FLASH overflow.jpg 
Views:	931 
Size:	21.9 KB 
ID:	7618

    Not sure how to attach/upload the sketch as I am new to this forum, but here is the section I have imported from the 3-3 sketch into the bottom of the FFT sketch along with inserting the necessary TFT setup and include statements in the top part. Is it possible to print to the display as well as the serial port? I have reduced the variable "n" to an integer for the leftNumber, but somehow it is creating a FLASH overflow?

    int leftNumber = (int)n; // Change leftNumber to integer of n

    if (msecs > 15) {
    // if (n.available() {
    msecs = 0;
    delay(10); // wait for library to parse WAV inf - is this necessary
    // float rightNumber = n;
    Serial.print(leftNumber);
    Serial.print(", ");
    // Serial.print(rightNumber);
    // Serial.println();

    // draw the verticle bars
    // int height = n * 240;
    // tft.fillRect(60, 280 - height, 40, height, ILI9341_GREEN);
    // tft.fillRect(60, 280 - 240, 40, 240 - height, ILI9341_BLACK);
    // height = n * 240;
    // tft.fillRect(140, 280 - height, 40, height, ILI9341_GREEN);
    // tft.fillRect(140, 280 - 240, 40, 240 - height, ILI9341_BLACK);
    // a smarter approach would redraw only the changed portion...

    // draw numbers underneath each bar
    tft.setFont(Arial_14);
    tft.fillRect(60, 284, 40, 16, ILI9341_BLACK);
    tft.setCursor(60, 284);
    tft.print(leftNumber);
    // tft.fillRect(140, 284, 40, 16, ILI9341_BLACK);
    // tft.setCursor(140, 284);
    // tft.print(rightNumber);
    }
    // }
    }
    Last edited by jshooks; 07-14-2016 at 04:34 AM. Reason: Tried something else, but didn't work

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    17,127
    Quote Originally Posted by jshooks View Post
    ... Not sure how to attach/upload the sketch ...
    See post #3 or #4 above for CODE insertion. And see post #7 about creating a new thread ... perhaps there or in "Technical Support & Questions"

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,973
    Quote Originally Posted by jshooks View Post
    The sketch compiles except at the end it gives the following error (region 'FLASH' overflow by 3768 bytes):
    This means your program is too large to fit into Teensy's flash memory.

    The FFT code uses large lookup tables that consume a lot of flash memory. If you're using the example which plays a guitar sound (can't see all of your code... you didn't follow the Forum Rule... so I'm trying to help with blind guessing), that data for the guitar also consumes a lot of memory. The fonts for the display are also large, if you use any of the larger sizes (again, can only see Arial_14, hard to know if you've got any others).

    You need to trim some stuff from your program so it'll fit into Teensy's memory. Especially if you have that guitar sound in your code, deleting that should free up plenty of space.

  13. #13
    https://forum.pjrc.com/threads/37218...-bad-soldering
    Teensy 3.2 Through-hole damaged due to bad soldering

  14. #14
    I'm searching for weight, dimensions, voltage & amperage for Teensy 3.1 and 3.5. Would you provide me such info please ?

  15. #15
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,594
    Everything is in the data sheets which you can download from the prjc.com website. Attention: The Teensy 3.1 is discontinued in favor of the more robust 3.2

  16. #16
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,656
    @Paul, @Robin - This thread has been spammed a few times.

    Wonder if it would make sense, to edit this thread, and maybe remove most everything except the first posting, where you might merge in a few of the details from other postings, like use the # button to get the code tags, which is now also available on the quick reply....

    And then lock it.

  17. #17
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    4,090
    I vote for bumping this thread all the time, it might help people read it eventually since the static red text is ignored lol

  18. #18
    Junior Member
    Join Date
    Apr 2018
    Posts
    13
    Hi! I have written a code in Keil and am using Teensy 3.2 and its audio shield. I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated. Here is the source code

    Code:
    #include <MK20D7.h>
    #include "kinetis.h"
    
    #define SET(x,b) x|=(1UL<<b)
    #define CLR(x,b) x=x&(~(1UL<<b))
    #define CHK(x,b) (x&(1UL<<b))
    #define TOG(x,b) x^=(1UL<<b)
    uint16_t ana_ctrl;
    uint8_t address = 0x0A;
    uint8_t A = 0, A1 = 0x14 ;
    
    
    #define SGTL5000_I2C_ADDR_CS_LOW    0x0A // CTRL_ADR0_CS pin low (normal configuration)
    #define SGTL5000_I2C_ADDR_CS_HIGH    0x2A // CTRL_ADR0_CS pin high
    
    void I2C_Write(int x) ;
    void I2C_Read( int y);
    
    volatile uint32_t msTicks; /* counts 1ms timeTicks */
    
    
    /*----------------------------------------------------------------------------
      SysTick_Handler
      ----------------------------------------------------------------------------*/
    void SysTick_Handler(void) {
      msTicks++; //increment counter necessary in Delay()//
    }
    
    
    /*------------------------------------------------------------------------------
      delays number of tick Systicks (happens every 1 ms)
      ------------------------------------------------------------------------------*/
    
    
    __INLINE static void Delay (uint32_t dlyTicks) {
      uint32_t curTicks;
    
      curTicks = msTicks;
      while ((msTicks - curTicks) < dlyTicks);
    }
    
    
    void delay_us(int xyz)
    {
      uint16_t MN = 18 * xyz;
      for (int mn = 0; mn <= MN; mn++)
      {
      }
    }
    
    long a = 1 , b = 0, c = 0, d = 0;
    
    /*---------------------------LED Configuration------------------------------------*/
    void Led_Config(void)
    {
      SIM -> SCGC5 |= (1UL << 11);
      PORTC -> PCR[5] |= (1UL << 8);
      PORTC -> PCR[5] |= (1UL << 6);
      PTC -> PDDR |= (1UL << 5);
      PTC -> PDOR |= 0;
    }
    
    void Led_On()
    {
      PTC -> PDOR |= (1UL << 5);
    }
    
    
    void Led_Off()
    {
      PTC -> PDOR = 0;
    
    }
    
    
    /*----------------------------I2C COnfiguration---------------------------------------*/
    void I2C_config(void)
    {
      SIM -> SCGC4 |= (1UL << 6);
      SIM -> SCGC5 |= (1UL << 10);
    
      PORTB -> PCR[2] |= (1UL << 9); //SCL Initalize//
      PORTB -> PCR[3] |= (1UL << 9); //SDA Initalize//
    
      SET(PORTB -> PCR[2], 1);
      SET(PORTB->PCR[3], 1); //Pullup enable//
    
      SET(PORTB -> PCR[2], 0); //Pull select//
      SET(PORTB->PCR[3], 0);
    
      SET(PORTB -> PCR[2], 2); //Slew Rate Enable//
      SET(PORTB->PCR[3], 2);
    
      SET(PORTB -> PCR[2], 6); //Drive Strength Enable//
      SET(PORTB->PCR[3], 6);
    
      SET(PORTB -> PCR[2], 5); //Open Drain Enable//
      SET(PORTB->PCR[3], 5);
    
      SET(PORTB->PCR[3], 16); //IRQC at rising edge in SDA//
      SET(PORTB->PCR[3], 19);
    
      SET(PORTB->PCR[3], 24);
      I2C0_F = 0X13;
    
    }
    
    /*----------------------I2S config-------------------------------*/
    void I2S_Config()
    {
      SET(SIM_SCGC6, 15);
      SET(SIM_SCGC5, 11);
      SET(PORTC->PCR[6], 10);
      SET(PORTC->PCR[6], 9);
    
      SET(PORTC->PCR[6], 1);
      SET(PORTC->PCR[6], 5);
      SET(PORTC->PCR[6], 6);
    
      I2S0_MCR |= 0x40000000;
      I2S0_MDR |= 0x0006327C;
    }
    /*------------------------------------------Start and Stop Signals-------------------------------------------*/
    void StartConfig()
    {
      SET(PTB -> PDOR, 2);//SCL HIGH//
      SET(PTB -> PDOR, 3); //SDA HIGH//
      delay_us(100);
      CLR(PTB -> PDOR , 3); //SDA LOW//
    }
    
    void StopConfig()
    {
      CLR(PTB -> PDOR, 3); //SDA LOW//
      delay_us(100);
      SET(PTB -> PDOR, 3); //SDA HIGH//
      CLR(PTB -> PDOR, 2);//SCL LOW//
    }
    
    
    void ack()
    {
      while (CHK(PTB -> PDOR, 3));
    }
    
    void I2C_Write(x)
    {
      I2C0_D = x;
      ack();
    
      Delay(10);
      while (!CHK(I2C0_S, 1));
      while ((CHK(I2C0_S, 0)));
      SET(I2C0_S, 1);
    
    }
    
    
    void I2C_Read(y)
    {
      y = I2C0_D;
    }
    
    void Master_Write( uint8_t data)
    {
    
      SET(I2C0_S, 1);
      SET(I2C0_S, 4);
    
      I2C0_C1 = 0 ;
    
      SET(I2C0_C1, 6);
      SET(I2C0_C1, 7);
      SET(I2C0_C1, 4);
      SET(I2C0_C1, 5);
    
      StartConfig();
    
      if (CHK(I2C0_C1, 5))
      {
    
    
        I2C0_C1 = 0xF4 ;
    
        Delay(5);
    
        if (CHK(I2C0_S, 5))
    
        {
    
          I2C_Write(A1);
          I2C_Write(CHIP_ANA_POWER >> 8);
          I2C_Write(CHIP_ANA_POWER);
        }
    
        else
        {
    
        }
    
      }
    
    }
    
    
    
    void write(unsigned int reg, unsigned int val)
    {
      StartConfig();
      SET(I2C0_C1, 5);
    
      Master_Write(reg >> 8);
      Master_Write(reg);
      Master_Write(val >> 8);
      Master_Write(val);
    
      CLR(I2C0_C1, 5);
    
      StopConfig();
    
      Led_On();
      Delay(200);
      Led_Off();
      Delay(100);
    }
    
    
    
    
    
    /*----------------------------------------------Main Program Start-----------------------------------------*/
    int main(void)
    {
      uint16_t ana_ctrl;
      SystemCoreClockUpdate(); /* Get Core Clock Frequency */
      SysTick_Config(SystemCoreClock / 1000); /* Generate interrupt each 1 ms */
      Delay(500);
    
      Led_Config();
      I2C_config();
      I2S_Config();
    
      Master_Write(0x20);
    
      while (1)
      {
    
      }
    }
    
    
    void SGTL_enable()
    {
    
    
      Delay(5);
    
      write(CHIP_ANA_POWER, 0x4060); // VDDD is externally driven with 1.8V
      write(CHIP_LINREG_CTRL, 0x006C); // VDDA & VDDIO both over 3.1V
      write(CHIP_REF_CTRL, 0x01F2); // VAG=1.575, normal ramp, +12.5% bias current
      write(CHIP_LINE_OUT_CTRL, 0x0F22); // LO_VAGCNTRL=1.65V, OUT_CURRENT=0.54mA
      write(CHIP_SHORT_CTRL, 0x4446); // allow up to 125mA
      write(CHIP_ANA_CTRL, 0x0137); // enable zero cross detectors
      write(CHIP_ANA_POWER, 0x40BF); // power up: lineout, hp, adc, dac
      write(CHIP_DIG_POWER, 0x0073); // power up all digital stuff
      Delay(400);
      write(CHIP_LINE_OUT_VOL, 0x1D1D); // default approx 1.3 volts peak-to-peak
      write(CHIP_CLK_CTRL, 0x0004); // 44.1 kHz, 256*Fs
      write(CHIP_I2S_CTRL, 0x0130); // SCLK=32*Fs, 16bit, I2S format
      // default signal routing is ok?
      write(CHIP_SSS_CTRL, 0x0000); // ADC->I2S, I2S->DAC
      write(CHIP_ADCDAC_CTRL, 0x0000); // disable dac mute
      write(CHIP_DAC_VOL, 0x3C3C); // digital gain, 0dB
      write(CHIP_ANA_HP_CTRL, 0x0000); // set volume (lowest level)
      write(CHIP_ANA_CTRL, 0x0122); // enable zero cross detectors
    
    }
    Last edited by Paul; 04-20-2018 at 07:33 AM. Reason: added code tags, and auto-format code white space

  19. #19
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    4,090
    ouch! code brackets???

  20. #20
    Administrator Paul's Avatar
    Join Date
    Oct 2012
    Posts
    444
    Easy enough. Edited the post.

    @Defragster, KurtE & other "plus" users... please feel free to add code tags if you see these messages. Just add a quick note in the reason for editing field.

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,973
    Quote Originally Posted by jrdlm View Post
    I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated.
    Looks like you're implementing I2C with bit bashing the GPIO registers. You probably need to add many more software delays, since the chip is much faster than the rise times of those signals. For example, I see busy loops that wait for the low->high transition and then the instant that slowly rising voltage hits the logic threshold, you do stuff on other pins without any extra delay to allow the signal to keep rising well into the logic high noise margin. That sort of thing might work, but on chips this fast you probably need more delays.

    Or you could try using the Wire or i2c_t3 libraries for the I2C hardware. Even if you never intend to run Arduino, you could use the code as a guide to get I2C working reliably (if Keil doesn't provide anything that works?)

    https://github.com/PaulStoffregen/Wi...ireKinetis.cpp

    If you don't go with working I2C code, maybe get a cheap logic analyzer or scope with protocol analysis to view the waveforms. That'll almost certainly show where you're not implementing I2C correctly.

  22. #22
    Junior Member
    Join Date
    Apr 2018
    Posts
    13
    I tried what you suggested but the issue hasn't been solved yet. Is there any other way to get this done? I also checked the cpp file you mentioned and found that I have been doing mostly the same things that you have done there.

  23. #23
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,656
    Quote Originally Posted by jrdlm View Post
    I tried what you suggested but the issue hasn't been solved yet. Is there any other way to get this done? I also checked the cpp file you mentioned and found that I have been doing mostly the same things that you have done there.
    Not sure what you are saying here? Did you try by using the Wire library or i2c_t3? Also mostly doing the same things?

    Also might help to know what the issues are... You are not getting the signals? At all? Or only in some specific cases?

    P.S. - Wish this was on it's own thread instead of this global sticky thread...

  24. #24
    Junior Member
    Join Date
    Apr 2018
    Posts
    13
    I ran into some problems when I connected the Teensy to a DSO. There was no SCL clock signal generated. Can someone take a look at my I2C initialization and start and stop signal codes and point out any problems with it? Thanks.



    Quote Originally Posted by jrdlm View Post
    Hi! I have written a code in Keil and am using Teensy 3.2 and its audio shield. I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated. Here is the source code

    Code:
    #include <MK20D7.h>
    #include "kinetis.h"
    
    #define SET(x,b) x|=(1UL<<b)
    #define CLR(x,b) x=x&(~(1UL<<b))
    #define CHK(x,b) (x&(1UL<<b))
    #define TOG(x,b) x^=(1UL<<b)
    uint16_t ana_ctrl;
    uint8_t address = 0x0A;
    uint8_t A = 0, A1 = 0x14 ;
    
    
    #define SGTL5000_I2C_ADDR_CS_LOW    0x0A // CTRL_ADR0_CS pin low (normal configuration)
    #define SGTL5000_I2C_ADDR_CS_HIGH    0x2A // CTRL_ADR0_CS pin high
    
    void I2C_Write(int x) ;
    void I2C_Read( int y);
    
    volatile uint32_t msTicks; /* counts 1ms timeTicks */
    
    
    /*----------------------------------------------------------------------------
      SysTick_Handler
      ----------------------------------------------------------------------------*/
    void SysTick_Handler(void) {
      msTicks++; //increment counter necessary in Delay()//
    }
    
    
    /*------------------------------------------------------------------------------
      delays number of tick Systicks (happens every 1 ms)
      ------------------------------------------------------------------------------*/
    
    
    __INLINE static void Delay (uint32_t dlyTicks) {
      uint32_t curTicks;
    
      curTicks = msTicks;
      while ((msTicks - curTicks) < dlyTicks);
    }
    
    
    void delay_us(int xyz)
    {
      uint16_t MN = 18 * xyz;
      for (int mn = 0; mn <= MN; mn++)
      {
      }
    }
    
    long a = 1 , b = 0, c = 0, d = 0;
    
    /*---------------------------LED Configuration------------------------------------*/
    void Led_Config(void)
    {
      SIM -> SCGC5 |= (1UL << 11);
      PORTC -> PCR[5] |= (1UL << 8);
      PORTC -> PCR[5] |= (1UL << 6);
      PTC -> PDDR |= (1UL << 5);
      PTC -> PDOR |= 0;
    }
    
    void Led_On()
    {
      PTC -> PDOR |= (1UL << 5);
    }
    
    
    void Led_Off()
    {
      PTC -> PDOR = 0;
    
    }
    
    
    /*----------------------------I2C COnfiguration---------------------------------------*/
    void I2C_config(void)
    {
      SIM -> SCGC4 |= (1UL << 6);
      SIM -> SCGC5 |= (1UL << 10);
    
      PORTB -> PCR[2] |= (1UL << 9); //SCL Initalize//
      PORTB -> PCR[3] |= (1UL << 9); //SDA Initalize//
    
      SET(PORTB -> PCR[2], 1);
      SET(PORTB->PCR[3], 1); //Pullup enable//
    
      SET(PORTB -> PCR[2], 0); //Pull select//
      SET(PORTB->PCR[3], 0);
    
      SET(PORTB -> PCR[2], 2); //Slew Rate Enable//
      SET(PORTB->PCR[3], 2);
    
      SET(PORTB -> PCR[2], 6); //Drive Strength Enable//
      SET(PORTB->PCR[3], 6);
    
      SET(PORTB -> PCR[2], 5); //Open Drain Enable//
      SET(PORTB->PCR[3], 5);
    
      SET(PORTB->PCR[3], 16); //IRQC at rising edge in SDA//
      SET(PORTB->PCR[3], 19);
    
      SET(PORTB->PCR[3], 24);
      I2C0_F = 0X13;
    
    }
    
    /*----------------------I2S config-------------------------------*/
    void I2S_Config()
    {
      SET(SIM_SCGC6, 15);
      SET(SIM_SCGC5, 11);
      SET(PORTC->PCR[6], 10);
      SET(PORTC->PCR[6], 9);
    
      SET(PORTC->PCR[6], 1);
      SET(PORTC->PCR[6], 5);
      SET(PORTC->PCR[6], 6);
    
      I2S0_MCR |= 0x40000000;
      I2S0_MDR |= 0x0006327C;
    }
    /*------------------------------------------Start and Stop Signals-------------------------------------------*/
    void StartConfig()
    {
      SET(PTB -> PDOR, 2);//SCL HIGH//
      SET(PTB -> PDOR, 3); //SDA HIGH//
      delay_us(100);
      CLR(PTB -> PDOR , 3); //SDA LOW//
    }
    
    void StopConfig()
    {
      CLR(PTB -> PDOR, 3); //SDA LOW//
      delay_us(100);
      SET(PTB -> PDOR, 3); //SDA HIGH//
      CLR(PTB -> PDOR, 2);//SCL LOW//
    }
    
    
    void ack()
    {
      while (CHK(PTB -> PDOR, 3));
    }
    
    void I2C_Write(x)
    {
      I2C0_D = x;
      ack();
    
      Delay(10);
      while (!CHK(I2C0_S, 1));
      while ((CHK(I2C0_S, 0)));
      SET(I2C0_S, 1);
    
    }
    
    
    void I2C_Read(y)
    {
      y = I2C0_D;
    }
    
    void Master_Write( uint8_t data)
    {
    
      SET(I2C0_S, 1);
      SET(I2C0_S, 4);
    
      I2C0_C1 = 0 ;
    
      SET(I2C0_C1, 6);
      SET(I2C0_C1, 7);
      SET(I2C0_C1, 4);
      SET(I2C0_C1, 5);
    
      StartConfig();
    
      if (CHK(I2C0_C1, 5))
      {
    
    
        I2C0_C1 = 0xF4 ;
    
        Delay(5);
    
        if (CHK(I2C0_S, 5))
    
        {
    
          I2C_Write(A1);
          I2C_Write(CHIP_ANA_POWER >> 8);
          I2C_Write(CHIP_ANA_POWER);
        }
    
        else
        {
    
        }
    
      }
    
    }
    
    
    
    void write(unsigned int reg, unsigned int val)
    {
      StartConfig();
      SET(I2C0_C1, 5);
    
      Master_Write(reg >> 8);
      Master_Write(reg);
      Master_Write(val >> 8);
      Master_Write(val);
    
      CLR(I2C0_C1, 5);
    
      StopConfig();
    
      Led_On();
      Delay(200);
      Led_Off();
      Delay(100);
    }
    
    
    
    
    
    /*----------------------------------------------Main Program Start-----------------------------------------*/
    int main(void)
    {
      uint16_t ana_ctrl;
      SystemCoreClockUpdate(); /* Get Core Clock Frequency */
      SysTick_Config(SystemCoreClock / 1000); /* Generate interrupt each 1 ms */
      Delay(500);
    
      Led_Config();
      I2C_config();
      I2S_Config();
    
      Master_Write(0x20);
    
      while (1)
      {
    
      }
    }
    
    
    void SGTL_enable()
    {
    
    
      Delay(5);
    
      write(CHIP_ANA_POWER, 0x4060); // VDDD is externally driven with 1.8V
      write(CHIP_LINREG_CTRL, 0x006C); // VDDA & VDDIO both over 3.1V
      write(CHIP_REF_CTRL, 0x01F2); // VAG=1.575, normal ramp, +12.5% bias current
      write(CHIP_LINE_OUT_CTRL, 0x0F22); // LO_VAGCNTRL=1.65V, OUT_CURRENT=0.54mA
      write(CHIP_SHORT_CTRL, 0x4446); // allow up to 125mA
      write(CHIP_ANA_CTRL, 0x0137); // enable zero cross detectors
      write(CHIP_ANA_POWER, 0x40BF); // power up: lineout, hp, adc, dac
      write(CHIP_DIG_POWER, 0x0073); // power up all digital stuff
      Delay(400);
      write(CHIP_LINE_OUT_VOL, 0x1D1D); // default approx 1.3 volts peak-to-peak
      write(CHIP_CLK_CTRL, 0x0004); // 44.1 kHz, 256*Fs
      write(CHIP_I2S_CTRL, 0x0130); // SCLK=32*Fs, 16bit, I2S format
      // default signal routing is ok?
      write(CHIP_SSS_CTRL, 0x0000); // ADC->I2S, I2S->DAC
      write(CHIP_ADCDAC_CTRL, 0x0000); // disable dac mute
      write(CHIP_DAC_VOL, 0x3C3C); // digital gain, 0dB
      write(CHIP_ANA_HP_CTRL, 0x0000); // set volume (lowest level)
      write(CHIP_ANA_CTRL, 0x0122); // enable zero cross detectors
    
    }

  25. #25
    Junior Member
    Join Date
    Jul 2019
    Posts
    2
    I have a teensy 3.2 and the Octo 2811 hooked up to my visual pinball system. I have a two screen layout. As soon as I connect the teensy to the USB port and I try to run a game on pinball x the b-2s screen opens up but any machine that uses the DMD,for example theater of magic or Addams family, DMD does not come up. Once I disconnect the teensy from the USB port and I restart the tables the DMD shows up again. Any other table that does not have DMD open up fine and the b2s work as it should. What could be the problem. Do you have any suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •