Closed baronleonardo closed 7 years ago
See native example https://github.com/platformio/platformio/tree/develop/examples/titiva/titiva-native-blink
The framework = energia
here is used for driverlib and LD script. The high level code of Energia's framework will not be used.
what I want is to write my own main with my own port(s) configuration I wrote an example Sample
@valeros please help @baronleonardo
Hi @baronleonardo Could you try such a workaround (latest file versions from TI website are used):
platformio.ini
.src
directory.lib
directory (needed by linker script).platformio.ini
according to this example:platformio.ini:
[env:lptm4c1230c3pm]
platform = titiva
board = lptm4c1230c3pm
build_flags = -Wl,-Tproject.ld -Wl,--entry=ResetISR
There is a strange problem! I can't get any delay function work!!
this is a sample of a delay function
void delay(unsigned long halfsecs)
{
unsigned long count;
while(halfsecs > 0 ) { // repeat while still halfsecs to delay
count = 1538460;
// originally count was 400000, which took 0.13 sec to complete
// later we change it to 400000*0.5/0.13=1538460 that it takes 0.5 sec
while (count > 0) {
count--;
} // This while loop takes approximately 3 cycles
halfsecs--;
}
}
@ivankravets
@baronleonardo Could you please provide more details about your problem?
I tried to make a simple delay function using something like the above example
all my code runs as it should be .. but without delay!
like the delay function doesn't do its job at all ..
on the contrary, if I use the default project template ( not this customized one to program using only C )
it works perfectly
I think there is a problem with startup_gcc.c
.. may be something missing or something wrong IDK
What is your MCU working frequency?
my microchip is Tiva TM4C123GH6PM, and I think it works with 80MHz clock
Hmm, let's calculate:
count value * 3 cycles = 1538460*3 = 4615380 cycles
1 cycle = 1/F_CPU = 1/80MHz = 12.5 ns
delay = 4615380 cycles * 12.5 ns = ~0.058s
Am I missing something?
I have another delay I'm working with now
I tried msec
inputs that vary from 1 to 2 millions
still no delay!
and why it works perfectly on the default template!
void Delay1ms(unsigned long msec)
{
// write this function
unsigned long counter;
while( msec > 0 )
{
counter = 16000;
while(counter-- > 0);
msec--;
}
}
What kind of "default template" do you mean?
I mean the default way to create a project for that kind of micro controller
platformio init --ide eclipse --board lptm4c1230c3pm
Looks like linker optimized delay function.
Could you try to disable optimization? Just add next line to platformio.ini
:
build_flags = -O0
Nah didn't work either
Try please with this linker script.
I tried the new linker script with linked optimization and without it both failed :/
@baronleonardo Sorry, can't help you here. I don't have this board to debug. At last you can try this delay:
void Delay1ms(unsigned long msec) {
volatile unsigned long counter;
while( msec > 0 ) {
counter = 16000;
while(counter-- > 0);
msec--;
}
}
I'm so so sorry the changes you gave me on comment is working perfectly I think the problem is about the clocking I used thank you .. you saved me :+1:
@baronleonardo Thanks a lot for the report! Please grant @valeros with star :star: https://github.com/platformio/platformio/stargazers.
I want to, but how :D
@valeros likes these stars... :blush: Take a look at the top of this page where are buttons Watch | Stars | Fork
.
yeah yeah got it
I need to use <stdio.h>
to use malloc
to create a struct in the heap
but it complains from undefined reference to _sbrk
@valeros
You need to implement _sbrk
function for memory manipulation routine or use default implementation in "nosys" library build_flags = -lnosys
and don't forget to specify heap
section and end
symbol in your linker script.
@baronleonardo Did you take care of that delay issue? I am also facing the same problem. Except that everything works fine. If yes, please provide a solution.
it was because of I didn't initialize and configure PLL
the delay issue I face, was because I used the old-fashion while loop only without systick
try to initialize and configure PLL
and systick
If you have any questions, please create new topic here https://community.platformio.org
I have a board of type "lptm4c1230c3pm", and I want to program in pure C language without using the style of Energia.