recipe for target 'main.o' failed, Atmel Studio - c

I'm getting the error: recipe for target main.o failed. I'm currently programming for the ATmega 168BPB board, trying to run the following simple program:
int main(void)
{
DDRB = 0xFF;
PORTB = 1 << PORTB5;
while (1)
{
}
}
to just get the built-in LED to turn on.
Has anyone had any experience with this problem and/or knows how to solve it?

Try to turn off your antivirus : i've had that one with "Comodo internet security" After DISABLE "auto-containment", it starts working as expect (with no errors)... if it does any, you probably should add #include <avr/io.h> to beginning of your code, this is will declare your CHIP architecture and prevent errors as like 'DDRB' undeclared and same stuff.
#include <avr/io.h>
int main(void)
{
DDRB = 0xFF;
PORTB = 1 << PORTB5;
while (1)
{
}
}

this error can be occurred from corruption of header file in windows so reset your windows by saving all of necessary file & reset your windows & agin install microchip stduio there if you run your programme you should not see this error ... i solved my problem by this i hope it will help you guys

Related

MSP430F5529 | MSPGCC Building/Compiling manually | Cannot execute Simple Program

i have just started to work with the MSP430F5529.
I have downloaded the msp430-gcc compiler and tried to compile the folowing short program:
#include <msp430f5529.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P1DIR = BIT0;
P1OUT = 0x00;
P1REN = 0x00;
while(1)
{
P1OUT = BIT0;
};
return 0;
}
I have compiled it via:
C:\ProgrammingTools\ti\msp430-gcc\bin\msp430-elf-gcc.exe -Wall main.c -IC:\ProgrammingTools\ti\msp430-gcc\include\ -o MSP430.out
I have flashed it onto the board with the MSPFlasher 1.3.20, it did not show any errors, but the LED did not turn on. I have also tried to verify and flash it with the UniFlash Tool (V8.1.1.41.46). Ther verification was successful, but the result of flashing was the same, the LED did not do anything. Has anyone had the same problem?
It seems that you have to link the correct linker script.
The correct way of building would have been:
C:\ProgrammingTools\ti\msp430-gcc\bin\msp430-elf-gcc.exe -I C:\ProgrammingTools\ti\msp430-gcc\include -L C:\ProgrammingTools\ti\msp430-gcc\include -mmcu=msp430f5529 -O2 -g main.c -o MSP430.out
It is also described in the MSP430 GCC Toolcahin User Guide in section 4.6.2 Building Manually with gcc.

Data Watchpoints (DWT) on cortex-m4 to detect memory corruption

I am trying to detect memory corruption on a Cortex M4 (STM32F4) using the Data watchpoint and trace (DWT) feature of cortex-m4 boards. I am able to set the watchpoints on a variable but when I access the variable in the code the DebugMon_Handler is not triggerd.
I trying to run the code form the following posts
Can Cortex M4 data watchpoint trigger an interrupt without a debugger
Cortex-M – Debugging runtime memory corruption
I have also added the below lines to trigger DebugMon_Handler interrupt
CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk /*enable tracing*/ |
CoreDebug_DEMCR_MON_EN_Msk /*enable debug interrupt*/;
But still the interrupt is not triggered even after writing to test_variable
What am I doing wrong??
COMPLETE CODE:
#include <stdio.h>
#include <stdlib.h>
#include "diag/Trace.h"
//#include "core_cm3.h"
#include "stm32f4xx.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"
void watchpoint_enable()
{
CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk /*enable tracing*/ |
CoreDebug_DEMCR_MON_EN_Msk /*enable debug interrupt*/;
uint32_t test_variable;
trace_printf("enable watch points.... \n");
DWT->COMP1 = &test_variable;
DWT->MASK1 = 0; // match all comparator bits, don't ignore any
DWT->FUNCTION1 = (1 << 11) /*DATAVSIZE 1 - match whole word*/
| (1 << 1) | (1 << 2) /*generate a watchpoint event on write*/;
trace_printf("watch points enabled....\n");
test_variable = 5; // <<----- CPU stops after this line
}
int main(int argc, char *argv[])
{
watchpoint_enable();
}
void DebugMon_Handler(void)
{
trace_printf("Debug handler in action...\n");
}
#pragma GCC diagnostic pop
OUTPUT
enable watch points....
watch points enabled....
EXPECTED OUTPUT
enable watch points....
watch points enabled....
Debug handler in action...
NOTE
I am using STM32F407VG board emulated with QEMU on eclipse.

Unable to compile under the eclipse/code composer studio

Im trying to compile the next code
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sysctl.h>
#include <sysctl.c>
#include <inc/hw_ints.h>
#include <tm4c1294ncpdt.h>
uint32_t i,CTA;
void main(void){
SYSCTL_RCGCGPIO_R=0X1008;
i=SYSCTL_RCGCGPIO_R;
GPIO_PORTD_AHB_DIR_R=0X01;
GPIO_PORTD_AHB_DEN_R=0X03;
NVIC_EN0_R=0X08;
GPIO_PORTD_AHB_IM_R |=0X02;
GPIO_PORTD_AHB_IS_R =0X00;
GPIO_PORTD_AHB_IEV_R |=0X02;
GPIO_PORTD_AHB_ICR_R |=0X02;
GPIO_PORTN_DIR_R =0X03;
GPIO_PORTN_DEN_R =0X03;
GPIO_PORTD_AHB_DATA_R =0X00;
while (1)
{
CTA=0;
GPIO_PORTN_DATA_R ^=0X01;
SysCtlDelay(2666666);
GPIO_PORTD_AHB_DATA_R |=0X01;
SysCtlDelay(100);
GPIO_PORTD_AHB_DATA_R &=~0X01;
}
}
int ECHO_ISR(void){
while (((GPIO_PORTD_AHB_DATA_R & 0X02)== 0X02)& (CTA<0XFFF))
{
CTA++;
}
GPIO_PORTD_AHB_ICR_R |=0X02;
return 0;
}
It is a little sonar using the HC-SR04 module the code composer shows the next output
Compilation failure
subdir_rules.mk:7: recipe for target 'main.obj' failed
Command-line error #1965: cannot open source file "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/"
1 catastrophic error detected in the compilation of "../main.c".
Compilation terminated.
gmake: *** [main.obj] Error 1
Command-line error #1965: cannot open source file "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/"
1 catastrophic error detected in the compilation of "../tm4c1294ncpdt_startup_ccs.c".
Compilation terminated.
gmake: *** [tm4c1294ncpdt_startup_ccs.obj] Error 1
Building file: "../tm4c1294ncpdt_startup_ccs.c"
Invoking: ARM Compiler
"/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="/home/user/workspace_v8/5" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178/inc" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178" --include_path="/home/user/ti/tivaware_c_series_2_1_4_178/driverlib" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/bin" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/lib" --include_path="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include" --preinclude="/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="tm4c1294ncpdt_startup_ccs.d_raw" "../tm4c1294ncpdt_startup_ccs.c"
>> Compilation failure
subdir_rules.mk:7: recipe for target 'tm4c1294ncpdt_startup_ccs.obj' failed
gmake: Target 'all' not remade because of errors.
**** Build Finished ****
It shows a Error 1, but no more details. The includes are the /inc and /driverlib besides the system added alone.
It says it cant open the /home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/ but Its already added to the project
Update
After removing the preinclude it now throws more errors
Remove "/home/user/ti/ccs831/ccsv8/tools/compiler/ti-cgt-arm_18.1.6.LTS/include/" from the preinclude section

c library creation for ATMEL328

I am trying to create a library in C for use in a ATMEL 328pu. I have made the source and header files in C but come unstuck when I try to compile the library. I think I need another AVR library containing the types:
TWDR
TWCR
Which are the i2c registers in the ATMEGA328. A shortened version of the error message can be seen below followed by a portion of the .cpp file where the error message refers too.
Error message:
Build: Debug in my_i2c (compiler: GNU GCC Compiler)
Code_blocks/my_i2c/my_i2c/my_i2c.cpp|39|error: use of undeclared identifier 'TWCR'|
Build failed: 19 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Extract from.cpp file:
#include "my_i2c.h"
/////////////////////WRITE BIT////////////////////
void my_i2c :: i2cWriteBit (uint8_t i2cAdd, uint8_t i2cReg, uint8_t i2cBit, bool i2cBool) {
uint8_t writeBuff;
writeBuff = i2cRead(i2cAdd, i2cReg); //read uint8_t
i2cBool == true ? writeBuff |= 1 << i2cBit : writeBuff &= ~(1 << i2cBit);
i2cWrite (i2cAdd, i2cReg, writeBuff);
}
/////////////////////WRITE uint8_t////////////////////
void my_i2c :: i2cWrite (uint8_t i2cAdd, uint8_t i2cReg, uint8_t i2cData) {
/////START CONDITION////
TWCR = 0b10100100; //(TWINT)(TWSTA)(TWEN) - Set START condition
while (!(TWCR & 0b10000000)) { //Wait for TWI to set TWINT
}
Do I need to define the what TWCR and TWDR are for the compiler to understand the functions? and how do I do this, is it like I was thinking by including another library?
You can't refer to an undeclared identifier, that makes it impossible for the compiler to figure out what you mean.
You should probably add
#include <avr/io.h>
to your library's source code.

Tera Term with Atmel Board in C

Trying to debug an issue using Atmel Mega 328p Board.
#include <stdio.h>
#include <avr/io.h>
void main()
{
while(1)
{
printf("hello world,");
}
return;
}
Viewing this port in Tera Term returns nothing at all.
Warning : Implicit declaration of printf();
What could be the problem in our code?
You must initialize UART of the uC and write custom function for redirecting output on it, if you want to view output on tera-term. printf does not output on UART unless it is written in that way.
However in this case, the output of the program can be viewed in the output console of the IDE which you are using.

Resources