Jump to content
43oh

madias

Members
  • Content Count

    49
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by madias

  1. I didn't recognized that the TI store do not offers free shipping anymore. Ok, thats their decision.

    BUT!!!!

    shipping costs to Austria or the Czech Republic are 21 USD, Germany or UK "only" about 14 USD.

     

    For anyone who doesn't know about europe: Austria and the czech Republik are neighboring countries to germany - only a few kilometers away, and ALL this countries are member of the EU. So wtf we should pay 7 USD more for shipping???

     

    thats enough for me, NOT to buy ANY TI-products anymore.

     

    regards

    Matthias

  2. Hello,

    I've done a TIVA C-123-Launchpad conversation of Henning Karlsen's LCD5510 library (it's much the same as the UTFT library).

    Everything is working, BUT:

    I've to eliminate following code (commented out part) in the *.cpp file, and I've to do it manually in "setup" sketch:

    LCD5110::LCD5110(int SCK, int MOSI, int DC, int RST, int CS)
    {
    	P_SCK	= portOutputRegister(digitalPinToPort(SCK));
    	B_SCK	= digitalPinToBitMask(SCK);
    	P_MOSI	= portOutputRegister(digitalPinToPort(MOSI));
    	B_MOSI	= digitalPinToBitMask(MOSI);
    	P_DC	= portOutputRegister(digitalPinToPort(DC));
    	B_DC	= digitalPinToBitMask(DC);
    	P_RST	= portOutputRegister(digitalPinToPort(RST));
    	B_RST	= digitalPinToBitMask(RST);
    	P_CS	= portOutputRegister(digitalPinToPort(CS));
    	B_CS	= digitalPinToBitMask(CS);
        
        /*
    	pinMode(_SCK,OUTPUT);
    	pinMode(_MOSI,OUTPUT);
    	pinMode(_DC,OUTPUT);
    	pinMode(_RST,OUTPUT);
    	pinMode(_CS,OUTPUT);
        */
    	SCK_Pin=SCK;
    	RST_Pin=RST;
        
    }
    

    If I leave this in the library, compiling is ok, but the TIVA freezes. I've compared it with the tiva conversation of the UTFT library line for line and I'm at a loss with this stupid easy code :)

    I've attached the whole conversation of the basic and graph library.

     

    Little example code (working):

    // LCD5110_Sleep_Mode (C)2014 Henning Karlsen
    // web: http://www.henningkarlsen.com/electronics
    //
    // This program is a demo of sleep mode.
    //
    // This program requires a Nokia 5110 LCD module.
    //
    // It is assumed that the LCD module is connected to
    // the following pins using a levelshifter to get the
    // correct voltage to the module.
    //      SCK  - Pin 8
    //      MOSI - Pin 9
    //      DC   - Pin 10
    //      RST  - Pin 11
    //      CS   - Pin 12
    //
    #include <LCD5110_Basic.h>
    LCD5110 myGLCD(PA_2,PA_3,PA_4,PB_6,PB_7);
    extern uint8_t SmallFont[];
    extern uint8_t MediumNumbers[];
    
    void setup()
    {
      pinMode(PA_2,OUTPUT);
    	pinMode(PA_3,OUTPUT);
    	pinMode(PA_4,OUTPUT);
    	pinMode(PB_6,OUTPUT);
    	pinMode(PB_7,OUTPUT);
      myGLCD.InitLCD();
    }
    
    void loop()
    {
      myGLCD.setFont(SmallFont);
      myGLCD.clrScr();
      myGLCD.print("Entering", CENTER, 0);
      myGLCD.print("Sleep Mode", CENTER, 8);
      myGLCD.print("in", CENTER, 16);
      myGLCD.print("Seconds", CENTER, 40);
      myGLCD.setFont(MediumNumbers);
      for (int s=10; s>=0; s--)
      {
        myGLCD.printNumI(s, CENTER, 24, 2, '0');
        delay(1000);
      }
      myGLCD.enableSleep();
      delay(5000);
      myGLCD.disableSleep();
      myGLCD.setFont(SmallFont);
      myGLCD.print("Awake again!", CENTER, 0);
      myGLCD.print("The screen was", CENTER, 16);
      myGLCD.print("cleared while", CENTER, 24);
      myGLCD.print("in Sleep Mode.", CENTER, 32);
      delay(5000);
    }
    

    Thanks 

    Matthias

    LCD5110_UTFT.zip

  3. If you're not using hardware oversampling, you can also do a simple lowpass filtering:

    Where weight is the interpolating value (1= no interpolating, 0.01 strong interpolating)

    rawValue is the the current analog reading, lastValue the value before.

    // filter the current result using a weighted average filter:
    float filter(float rawValue, float weight, float lastValue) {
      // run the filter:
      float result = weight * rawValue + (1.0-weight)*lastValue;
      // return the result:
      return result;
    }
    

    I've found in my snipplet folder some fooling around with mixing energia and driverlib:

     

    example for using the energia analogRead with hardware oversampling:

    #include <stdint.h>
    #include <stdbool.h>
    
    #define PART_TM4C123GH6PM
    #include "inc/tm4c123gh6pm.h"
    
    #include "inc/hw_memmap.h" 
    #include "inc/hw_types.h" 
    #include "driverlib/debug.h" 
    #include "driverlib/sysctl.h" 
    #include "driverlib/adc.h"
    
    void setup() {
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
     ADCHardwareOversampleConfigure(ADC0_BASE,64);
     Serial.begin(9600);
    }
    
    void loop() {
    
      int sensorValue = analogRead(A3);
      // print out the value you read:
      Serial.println(sensorValue/16);
      delay(1); // delay in between reads for stability
    }
    
  4. Hello and thank you for your answer and sorry for my delayed reply. I'd to think a little bit over.

    Ok, my description of "energia uses software pwm" is a little bit rough.

    But the main difference between the "old" stellaris launchpad and the new tiva driverlib style is, that the tiva has 2  build in pwm modules (see driver lib guide page 205ff)

    So my question is more:

    Is the new way of the tiva's (using the 2 pwm modules) faster than the "old" energia/timer way for the stellaris launchpad?

    The drawback of using the pwm modules is, that you 've to use only up to 16 hardcoded pins. I've attached a sheet with the different pinouts (row: "Hardware PWM" and "Energia PWM"), please ignore the "connected with" tab - it's for my project :)

    I dont need a special pwm mode with sync/dead band... just converting voltage like a DAC (but with the carrier frequency >60kHz, the "DAC output frequency" ist quiet low: <50-100Hz), so I read your link and get the conclusion to myself, that there should be no big advantage for me using the pwm module....

     

    Thank you and

    regards

     

    Matthias

    8-bit-synth-pinout-tiva-sheet.pdf

  5. Hello,

    I'm planning for a project the use of 12 Channels PWM (Frequency must be above 60khZ, because of driving some VCA´s and not getting into the audio range).

    As I know, Energia uses "software" PWM with the use of timers (the hardware PWM´s of the new TIVA's is not implimented).

     

    So my question is, may I can get some overall performance boost using the driverlib hardware PWM rather than the energia software version?

     

    Thanks

     

    regards

    Matthias

  6. Ok, it seems, that my DS201 is out of range for this measure, can someone check this two codes out with "real equipment"?

    Meanwhile I've stripped the code down to complete low level: (Measuring pin is PA7)

     

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_gpio.h"
    #define PART_TM4C123GH6PM
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/gpio.h"
    byte running=1;
    void setup()
    {
      GPIOPadConfigSet(GPIO_PORTA_BASE, 0xff, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
      GPIODirModeSet (GPIO_PORTA_BASE, 255, GPIO_DIR_MODE_OUT);
    }
    
    
    void loop()
    {
      while(1)
      {
      running=!running;
      HWREG(0x40004200)=running<<7;
      }
    }
  7. Hello,

    after fooling around a little bit, I recognize following driverlib behavior:

     

    While I get with this sketch about 450kHz on  my oscilloscope

     

    #include <stdint.h>
    #include <stdbool.h>
    
    
    #define PART_TM4C123GH6PM
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/gpio.h"
    byte running=1;
    void setup()
    {
      GPIOPadConfigSet(GPIO_PORTA_BASE, 0xff, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
      GPIODirModeSet (GPIO_PORTA_BASE, 255, GPIO_DIR_MODE_OUT);
    }
    
    
    void loop()
    {
      while(1)
      {
      running=!running;
      GPIOPinWrite(GPIO_PORTA_BASE,128,running<<7);
      }} 

    ...I'll get only 176kHz with the ROM_ equivalent:

     

    #include <stdint.h>
    #include <stdbool.h>
    
    
    #define PART_TM4C123GH6PM
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/gpio.h"
    byte running=1;
    void setup()
    {
      ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, 0xff, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
      ROM_GPIODirModeSet (GPIO_PORTA_BASE, 255, GPIO_DIR_MODE_OUT);
    }
    
    
    void loop()
    {
      while(1)
      {
      running=!running;
      ROM_GPIOPinWrite(GPIO_PORTA_BASE,128,running<<7);
      }
    }

    Does anyone have any idea why is that?

    Remember, that all energia stuff is related to the ROM_* commands (like wiring_digital.c)

     

     

  8. Ok, so I guess there are 3 "main libraries/wrappers" to use with tiva/stellaris:

    FatFs

    Petit FatFs (lightweight of FatFs)

    and  Sd2Card (original distributed with the Arduino IDE)

     

    I did a quick&dirty port of the Sd2Card Library, taken out of Arduino IDE 1.5.6 r2 for the Tiva/Stellaris, only changed some ARM settings, especially in the Sd2PinMap.h file: (at the top of the "arm" section): 

    uint8_t const SS_PIN = 32;
    uint8_t const MOSI_PIN = 8;
    uint8_t const MISO_PIN = 13;
    uint8_t const SCK_PIN = 11;

    because I need SPI Module(0)

    While in use don't forget to set in "Setup": 

    SPI.setModule(0);

    and get rid of the 

    while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
    lines in the examples and set up the CS Pin.
    Now many of Arduino written sketches will work right out of the box!
     
    Todo: more convenient selecting the SPI module and CS Pin, like 
    SD.begin(CS_Pin,Module)

    Attach Files:

    SD.zip = Port of the Arduino SDCard Library

    SD2Card_Tiva_examples.zip: some examples

    SD.zip

    SD2Card_Tiva_examples.zip

  9. Dear Rei Vilo,

    I think there is a misunderstanding: 

    Is the FatFs Library exactly the same as the adafruit sd library?

    Because you wrote on page 2 on this thread:

     

     

    Now, I'm no longer using the FatFs library but the SD library from Adafruit. It provides a higher level interface.

     

    Thorvard and I tried out the adafruit link, but this library need much of hands on.

    I'm a little bit confused right now :)

  10. Hello,

    as I was studying the (extremely good written!) driverlib documentation, i noticed the SysCtlPeripheralReady function.

    Because it is not always clear which Timer (TIMER,WTIMER,WATCHDOG) is currently in use (many of them are used with PWM and other stuff), I wrote this little helper sketch for my Tiva C.

    The definitions for other peripheral  can be read in "sysctl.h", I only used the timers to keep it short.

    I also included the SysCtlPeripheralPresent function, but I think it is meant, that a peripheral is physically available, so the "ready" function is the key. Try it out with some line of code with PWM stuff (with different pins) for example and see the difference!

    
    /*
    Little timer state helper
     no (c) by Matthias Diro
     */
    #include <stdint.h>
    #include <stdbool.h>
    #define PART_TM4C123GH6PM
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/sysctl.h"
    
    void setup()
    {
      Serial.begin(9600);
    }
    
    void loop()
    {
      Serial.println("---Timertest---");
      Serial.println("***Timer***");  
      for (int x=0;x<=5;x++)
      {
        Serial.print("Timer: ");    
        Serial.print(x);
        Serial.print(" present: ");
        Serial.print(SysCtlPeripheralPresent(4026532864+x));
        Serial.print(" ready: ");
        Serial.println(SysCtlPeripheralReady(4026532864+x));
      }
      Serial.println("***WTimer***");
      for (int x=0;x<=5;x++)
      {
        Serial.print("WTimer: ");    
        Serial.print(x);
        Serial.print(" present: ");
        Serial.print(SysCtlPeripheralPresent(4026555392+x));
        Serial.print(" ready: ");
        Serial.println(SysCtlPeripheralReady(4026555392+x));
      }
      Serial.println("***Watchdogs***");
      for (int x=0;x<=1;x++)
      {
        Serial.print("Watchdog: ");    
        Serial.print(x);
        Serial.print(" present: ");
        Serial.print(SysCtlPeripheralPresent(4026531840+x));
        Serial.print(" ready: ");
        Serial.println(SysCtlPeripheralReady(4026531840+x));
      }
      Serial.println();
    
      while(1);
    }
    
    

    Maybe this little code helps some of you!

     

    Regards

    Matthias

  11. Hello,

    I'm trying to collect some standard procedures porting arduino(mostly avr, sam is easier) libraries to energia/lm4f. 

    Maybe all forum members could help together, creating a little howto:

     

    Porting libraries to Energia/Stellaris LM4F

    Version 2014-05-20

     

    1. First, it is necessary to examine the files to the following:

     

    1.1

    #if ARDUINO >= 100

    #include <Arduino.h> 

    #else

    #include <WProgram.h> 

    #endif

     

    and change it to:

    #include <Energia.h> 

    (or let #include <Arduino.h> as only line)

     

    1.2 change #include <pins_arduino.h> to #include <pins_energia.h>

     

    2. If PROGMEM was used:

    remove all PROGMEM and replace pgm_read_byte with *

    and better add a static const

     

    or insert this line on top: (Untested)

    #define PROGMEM

    #define pgm_read_byte(addr) (*(const unsigned char *)(addr))

     

    or insert:(Untested)

    #define pgm_read_word(data) *(data)

    #define pgm_read_byte(data) *(data)

    #define PROGMEM

     

    3. __delay_cycles macro

    3.1 easy way: use delayMicroseconds(xxx) where xxx is to try&error

    3.2 use SysCtlDelay(xxx); -> Thread: http://forum.stellarisiti.com/topic/1980-delay-cycles/

     

    4. Pin related macros/stuff

     

    4.1 insert:(Untested)

    #define cbi(reg, mask) GPIOPinWrite(reg, mask, 0)

    #define sbi(reg, mask) GPIOPinWrite(reg, mask, mask)

    #define pulse_high(reg, bitmask) { sbi(reg, bitmask); cbi(reg, bitmask); }

    #define pulse_low(reg, bitmask) { cbi(reg, bitmask); sbi(reg, bitmask); }

     

    4.2 Conversation: (now I need your help for converting!)

    Arduino / AVR:

    #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
    #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
    #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
    #define analogInPinToBit(P) (P)
    #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
    #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
    #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )

     

    So your help is desired, I'll update this thread as soon as I get new information.

    Maybe we can build together a conversation.h file, so we can include it to every library (for testing)

     

    Regards 

    Matthias

×
×
  • Create New...