Jump to content

jkabat

Members
  • Content Count

    59
  • Joined

  • Last visited

  • Days Won

    1

jkabat last won the day on September 9 2013

jkabat had the most liked content!

About jkabat

  • Rank
    Level 1

Profile Information

  • Location
    Hillsboro, OR
  1. @@sumotoy, I ran across this a while ago. Energia does not change the Stellaris/TivaC clock based on F_FPU. It is always 80Mhz! I modified Wiring.c timerInit() at one time to use F_CPU. However I also hadto modify timer5, and systick as well as the timer routines. I did this due to the fact that an application I had needed 50mhz for hardware interfaces. I later found out a way to get the H/W interface to run faster and abandoned this. I also changed timer5 to one of the wtimers in order to get 64 bits on millis() for loong running applications. I also found out later how to use the 32-bit millis(). I also believe there MAY have been a bug in millis that only gave 16-bit results due to math overflow/truncation. I don't quite remember. Regards John K Maker and Robot Builder
  2. @@CorB That actually should be OK. You might want to try: #pragma pack(1) ... define your structure here #pragma pack() You might be having problems with word alignment. The compiler may force uint16_t to be aligned on a word boundry. The pack(1) forces aligment to 1 byte. the pack() restores it to whatever the compiler is using. I have to do this all the time on my x86 stuff. regards John
  3. @@CorB, Here is a useful function; uint16_t swap16(uint16_t val) { return ((val & 0xFF) << 8) | ((val >> 8) & 0xFF); } data2=swap(data1); I make my own include files that conditionally compile based on the endian type of the host. All external items should be little endian. #ifdef WE_ARE_BIGENDIAN #define swap16_external(val) (((val & 0xFF) << 8) | ((val >> 8) & 0xFF))) #else #define swap16_external(val) (val) #endif
  4. @@CorB The enums may be generating 16-bit variables. I believe there is a gcc option to limit to 8 bits. Alternatively define them as uint8_t. Of course I may be totally wrong! Regards JohnK
  5. My order shipped last night and is on it's way from Dallas via FedEx! I guess Tivas are in stock and available. Thanks @@BravoV for letting us know about this.
  6. @@grahamf72, If was @@dellwoodbu who provided this information. Thanks to @@dellwoodbu again. JohnK
  7. grahamf72See this thread: http://forum.stellarisiti.com/topic/495-programming-lm4f-when-idc-usb-connector-destroyed/ This is from when I 1st had problems.
  8. I believe he has a direct drive LCD it takes raw24-bit RGB data, DotClock, HSYNC, VSYNC and some other lines. No controller as we know it. I have a 5" one and I hooked/am hooking it it to a SSD1963 development board from Tech Toys.
  9. @@PTB, in fast digital read: Move GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_IN); to ant init routine. Ony dnnest to be done before the read. use constants if possble in fast digial read: For port a pin 2 PA2 #define PORT_A GPIOA_BASE #define PIN2 ( (1<<2)<<2) value = (HWREG( PORT_A + (GPIO_O_DATA +PIN2)); The you can build somthing like the following: #define PORT_A GPIOA_BASE #define PIN2 ((1<<2) #define NUMBER_VALUES 4096 uint32_t pa2 _values[NUMBER_VALUES+1]; void fast_read_PA2(void) { int i; uint32_t *pValues=&VALUES[0] GPIODirModeSet(PORT_A,,PIN2, GPIO_DIR_MODE_OUT); FOR =0;I<number_values;i++,pValues++) { *Pvalues = HWREG( PORT_A + (GPIO_O_DATA +PIN2)); } Untested. Use at your ownrisk. I am still traveling. Johnk
  10. My Project, A replacement for the Stereo on my 1994 Chrsyler New Yorker. With added features: 1. Blutooth using Sparkfun BT-52 BT audio Board. (hadles i2S form radio bards - a plus) 2. AM/FM/SW tuner using Silcon Labs Si???? 3. Weather Radio using Si4707. 4. USB MP3 Played 5. 7" touch Display using Android tabled via ADK 6. GPS & Navigation 7. Monitor automobile funtions via the old Chrysler CCD bus. 8. CAN Bus interface to future use in another Car. 9. Rear view camera to display. 10. Possible CD player. 11. Interface to Tapster and/or speedwiki to provide real-time speed limits. This will replace the Sterio and feed auto to the built-in Infinity Amplifier in the trunk. The concept is the the display/control will do what I want not what some manufacturer decides I might like or what is good for me. The LMS3 will control all this stuff and act as a traffic cop for the data being passed around. Regrards John
  11. @@PTB Almost one microsecond per read is really gootd. Consider that 1usec is the limit of the hardware! The 3usec may be do to the overhead of the call to micros! Energia has a bain-damaged micros/and millis method anyhow. Try sample1=micros(); sampe2=micros(); Serail.prntln(sample2-sample1; This will give you an idea of the overhead. I am sorry I will not be able to help as I am leaving on a business trip tomorrow morning. I will be back thursday. If anyone is inerested here is my replacement for wiring.c to make timing more accurate. The old version had warp problems that limit the max value of millis to 65000 or so. I also only used 80mhz for the colck. I have enhanced it to used whatever frequency is defined by F_CPU. changes are also needed to main and lm4fcpp.ld. in main.c: Chare to call to timer_init: int main(void){ // change timer_init to use requested clock frequency // this means we may be able to change it on the fly if needed timerInit(F_CPU); Lm4fcpp.ld needs to be changed so the long long functions don't produce an error! /** * * lm4fcpp.ld - Linker configuration file for Energia c++ programs. * */ MEMORY { flash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 }REGION_ALIAS("REGION_TEXT", flash);REGION_ALIAS("REGION_RAM", ram);SECTIONS { .text : { _text = .; KEEP(*(.isr_vector)) *(.text .text* .gnu.linkonce.t.*) } > REGION_TEXT .preinit_array : { . = ALIGN(4); __preinit_array_start = .; KEEP (*(SORT(.preinit_array*))) KEEP (*(.preinit_array)) __preinit_array_end = .; } > REGION_TEXT .init_array : { . = ALIGN(4); __init_array_start = .; KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array)) __init_array_end = .; } > REGION_TEXT .rodata : { . = ALIGN(4); *(.rodata .rodata* .gnu.linkonce.r.*) . = ALIGN(4); } > REGION_TEXT .ARM.exidx : { __exidx_start = .; *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = .; } >REGION_TEXT _etext = .; .data : { . = ALIGN(4); _data = .; *(vtable) *(.data .data* .gnu.linkonce.d.*) _edata = .; } > REGION_RAM AT > REGION_TEXT .bss : { . = ALIGN(4); _bss = .; *(.bss .bss*) *(COMMON) . = ALIGN(4); _ebss = .; . = ALIGN(8); _end = .; } > REGION_RAM _jkend = .;}/* end of allocated ram is start of heap, heap grows up towards stack*/PROVIDE(end = _end);/* top of stack starts at end of ram, stack grows down towards heap */PROVIDE (_estack = ORIGIN(ram) + LENGTH(ram)); Wiring.c /* ************************************************************************ * wiring.c * * Arduino core files for MSP430 * Copyright (c) 2012 Robert Wessels. All right reserved. * * *********************************************************************** Derived from: wiring.c - Partial implementation of the Wiring API for the ATmega8. Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 David A. Mellis This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "Energia.h"#include <limits.h>#include "driverlib/rom_map.h"#include "driverlib/sysctl.h"#include "driverlib/timer.h"//// I have removed any frequency that is not an even number of MHZ// as this makes micros inaccurate//uint32_t freq_table[][2] ={ 80000000, SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 80,000,000 80 50000000, SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 50,000,000 50 40000000, SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 40,000,000 40 25000000, SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 25,000,000 25 20000000, SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 20,000,000 20 16000000, SYSCTL_SYSDIV_1 | SYSCTL_RCC_BYPASS | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 16,000,000 16 raw osc 10000000, SYSCTL_SYSDIV_20 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 10,000,000 10 8000000, SYSCTL_SYSDIV_2 | SYSCTL_RCC_BYPASS | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 8,000,000 8 5000000, SYSCTL_SYSDIV_40 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 5,000,000 5 4000000, SYSCTL_SYSDIV_4 | SYSCTL_RCC_BYPASS | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ, // 4,000,000 4 0, SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ // if not in table default to 80mhz};// these// no need to call SysCtlClockGetuint32_t System_Frequency;uint32_t System_Frequency_Mhz; // in Mhzvoid timerInit(uint32_t desiredFrequency){ uint16_t i; // search for the frequency wanted for (i=0;freq_table[i][0]!=0;i++) { if (desiredFrequency == freq_table[i][0] ) { break; } } // ok - got it (or the default) // set it SysCtlClockSet(freq_table[i][1]); System_Frequency = SysCtlClockGet(); System_Frequency_Mhz = System_Frequency / 1000000; // clocks per 1 us // we are not using this anymore but keep it around. // I may us it to give a time interrupt in my private OS/Supervisor if I need it // set periodic to 1 ms SysTickPeriodSet(System_Frequency / 10); //100ms 1/10 second SysTickEnable(); // //Initialize WTimer4 to be used as time-tracker since beginning of time // SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER4); //not tied to launchpad pin TimerConfigure(WTIMER4_BASE, TIMER_CFG_PERIODIC); TimerLoadSet64(WTIMER4_BASE, 0xFFFFFFFFFFFFFFFFl); //start at -1 and count down TimerEnable(WTIMER4_BASE, TIMER_A);}inline unsigned long micros(void){ // get the time value ond convert to positive unsigned long long cycles = ~ROM_TimerValueGet64(WTIMER4_BASE); // divide by clock in mhz - give micro seconds cycles /= System_Frequency_Mhz; return (cycles);}unsigned long millis(void){ unsigned long long cycles = ~ROM_TimerValueGet64(WTIMER4_BASE); cycles /= (System_Frequency / 1000ll); // note: that is LL at the end not 11! return (cycles);}/* Delay for the given number of microseconds. */void delayMicroseconds(unsigned int us){ unsigned long currTime; unsigned long endTime; endTime = micros() + us; do { currTime = micros(); } while (currTime <= endTime);}void delay(uint32_t milliseconds){ unsigned long i; for (i = 0; i < milliseconds; i++) { delayMicroseconds(1000); }}
  12. @@reaper7, That is what I was going to suggest. Just overloaded here a work today. @@PTB one thing you may want to do after applying @@reaper7s fix is to place the code for fastAnalogRead in place of the call. Anlternativly you should move the read and init routines up befor loop and place the __inline__ attribute on them. Sorry I am at work preparing for a trip and am not sure of the exact format. If you copy the code in place of fast... assign the result to sample[i++]= HWREG(ulBase + ADC_SSFIFO); in place of value[ulcount]. If you switch to another sequencer (o has an 8 deep fifo) this will handle the results automatically. You may have to modify some setting in fastAdcInit(pin) to get multiple reads. update: Use sequencer 0. I am not sure if all 8 steps need to be configured but you may need to add the following to init: ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 0, channel | ADC_CTL_IE ); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 1, channel | ADC_CTL_IE ); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 2, channel | ADC_CTL_IE ); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 3, channel | ADC_CTL_IE); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 4, channel | ADC_CTL_IE); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 5, channel | ADC_CTL_IE); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 6, channel | ADC_CTL_IE); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 7, channel | ADC_CTL_IE | ADC_CTL_END); (late edit: You may (or may not) neet to remove the" | ACD_CTL_IE" from all but the last entry. Only use this for SEQUENCER 0) Use at your own risk as I am unable to test this.
  13. Looks got for a project i have in mind. I'll take one if there are any left.
  14. @@PTB, I begin to see where I erred! I forgot to include the sequencer in the read of the fifo. The clue to this was the ucount was 8 not 1. this indicates the we were reading an 8 deep FIFO not a single one. (Sequencer 0) Also since value is only one entry were were overwriting something following it. That is why it never returned! So one more fix: change value to: uint16_t value[8]; just to be safe. change the end as follows: // // Get the offset of the sequence to be read. // ulBase = ADC0_BASE + (ADC_SEQ + (ADC_SEQ_STEP * SEQUENCER)); // // Read samples from the FIFO until it is empty. // ulCount = 0; while(!(HWREG(ulBase + ADC_SSFSTAT) & ADC_SSFSTAT0_EMPTY) && (ulCount < 8)) { // // Read the FIFO and copy it to the destination. // value[ulcount] = HWREG(ulBase + ADC_SSFIFO); // // Increment the count of samples read. // ulCount++; } return(value[0];
×
×
  • Create New...