getting errors in eclipse

Questions for programming 8051 microcontrollers in C or assembly using SDCC

Re: getting errors in eclipse

Postby joselalupa » Tue Dec 15, 2015 3:54 am

i thought i had the things well but now i realize i didn't, the tutorial is not compiling, here i attach a file showing the structure of my project so you can tell me please where should i copy the tutorial in order to get compiled, i deleted the flash folder content as a proof it is not creating the files, please help me solve this puzzle

Image
joselalupa
 
Posts: 32
Joined: Tue Aug 12, 2014 4:44 pm

Re: getting errors in eclipse

Postby brennen » Tue Dec 15, 2015 1:35 pm

All you need to do is make sure the tutorial and the SDK are unzipped into the same parent directory, then import both projects into your workspace in Eclipse. Make sure that the projects are open in Eclipse. Make sure that "Build Automatically" is *not* checked. Then click "Build All" and everything should compile. You may want to run a "Clean" first.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: getting errors in eclipse

Postby joselalupa » Tue Dec 15, 2015 6:27 pm

amazing, i love when i look like an idiot....i've done this before,several times, and i always get errors, now i did it again and it worked....thanks a lot for your patience
joselalupa
 
Posts: 32
Joined: Tue Aug 12, 2014 4:44 pm

Re: getting errors in eclipse

Postby brennen » Tue Dec 15, 2015 9:14 pm

Haha everything is easy once you get it to work once. ;-) You're very welcome.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: getting errors in eclipse

Postby joselalupa » Wed Dec 16, 2015 1:03 pm

a new one i want to ask you before modify project's properties, i don't want to mess up things.
i can't declare a simple string....it gives "type string could not be resolved" error but if i make a new c++ project it works fine, can i use string? can i send a 9 character string or should i deal with character array wich i want to avoid??
joselalupa
 
Posts: 32
Joined: Tue Aug 12, 2014 4:44 pm

Re: getting errors in eclipse

Postby brennen » Wed Dec 16, 2015 1:37 pm

There is no "string" type in C. That only exists in C++. Strings in C are implemented as "char *". Something like this:

Code: Select all
#include <stdio.h>

void main()
{
   char * test_string = "Hello world";

   printf("%s\n", test_string);
}
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: getting errors in eclipse

Postby joselalupa » Mon Dec 21, 2015 2:22 pm

weird stuff brenen, i've been playing with the code with no luck, not even with the default code you supply , the lights don't blink, i got another code that work but yours is pretty more clear to work, i'm going to paste it here, maybe you can have a clue of what is happening:


tx code


#include "reg24le1.h"
#include "main.h"
#include "nRF24L01.h"

/*
================================================================================
SPI_Exchange :
Exchange a byte via the MCU
input : dt, the byte to be sent
Output : The byte read from the slaver
================================================================================
*/
INT8U SPI_ExchangeByte( INT8U dt )
{
SPIRDAT = dt;
while( !( SPIRSTAT & 0x02 ) );
return SPIRDAT;
}

//RF interrupt
INT8U rf_flag = 0;
void RF_IRQ( void ) interrupt INTERRUPT_RFIRQ
{
INT8U i = L01_ReadIRQSource( );

if( i & ( 1<<RX_DR ) ) //Received data
{
rf_flag |= ( 1<<1 );
}
if( i & ( 1<<TX_DS ) ) //Send data OK
{
rf_flag |= ( 1<<2 );
}
if( i & ( 1<<MAX_RT ) ) //Send data fail
{
rf_flag |= ( 1<<3 );
}
L01_ClearIRQ( IRQ_ALL );
}
/*
================================================================================
UART_Init:
Initialize the UART
input : BaudIndex, the index of the baudrate of the UART, 0-7, 1200-115200
Output : None
================================================================================
*/
code unsigned int UART_BAUD_TBL[7] = { 607, 816, 920, 972, 998, 1011, 1015 };
//0----6,,,--> 1200, 2400, 4800, 9600, 19200, 38400, 57600
void UART_Init( unsigned char BaudIndex )
{
IEN0 &= ~( 1<<4 ); //Disable UART0 interrupt while initializeing
S0CON = ( 1<<6 ) | ( 1<<4 ); //MODE1, Enable receive
ADCON = 0x80; //Enable baudrate generator
PCON |= 0x80; //mode1
S0RELL = UART_BAUD_TBL[BaudIndex];
S0RELH = UART_BAUD_TBL[BaudIndex] >> 8;
IEN0 |= ( 1<<4 ); //Enable interrupt
P0DIR |= ( 1<<6 ); //P0.6, RXD, set as input
P0DIR &= ~( 1<<5 ); //P0.5, TXD, set as output
}
unsigned char TX_OK = 0;
static void UART0_ISR( void ) interrupt INTERRUPT_UART0
{
if( S0CON & ( 1<<1 ) )
{
//TX ok
S0CON &= ~( 1<<1 );
TX_OK = 1;
}
else if( S0CON & ( 1<<0 ) )
{
//RX ok
S0CON &= ~( 1<<0 );
}
}

void UART0_SendBuff( unsigned char *buff, unsigned char size )
{
while( size -- )
{
TX_OK = 0;
S0BUF = *buff ++;
while( TX_OK == 0 );
}
TX_OK = 0;
}
void UART0_SendStr( char* str )
{
UART0_SendBuff( ( unsigned char* ) str, strlen( str ) );
}
int main( void )
{
INT16U itmp;

CLKCTRL = ( CLKCTRL | 0x80 ) & ~0x08;
P0DIR = 0;

RFCON = 0x07;
RFCE = 0;
RFCKEN = 1; // Æô¶¯RFʱÖÓ
RF = 1; // ÔÊÐíRFÖжÏ
for( itmp = 0; itmp < 30000; itmp ++ );

UART_Init( 3 ); //9600
EA = 1;
UART0_SendStr( "nRF24LE1 TX test start!\r\n" );
RFCE = 1;
while( 1 )
{
P0 |= ( 1<<0 );
for( itmp = 0; itmp < 50000; itmp ++ );
for( itmp = 0; itmp < 50000; itmp ++ );
L01_Init( ); //Initialize the internal 24L01P
L01_SetTXMode( ); //Set as TX mode
L01_FlushTX( );
L01_FlushRX( );
rf_flag = 0;
L01_WriteTXPayload_Ack( ( INT8U* )"12345ABCDE\r\n", 12 );
RFCE = 1;
while( rf_flag == 0 );
if( rf_flag & ( 1<<1 ) ) //received
{

}
if( rf_flag & ( 1<<2 ) )
{
P0 ^= ( 1<<2 ) | ( 1<<3 ) | ( 1<<4 );
UART0_SendStr( "Send OK!\r\n" );
}
if( rf_flag & ( 1<<3 ) )
{
UART0_SendStr( "Send Error!\r\n" );
}
RFCE = 0;
rf_flag = 0;

}
}



rx code


#include "reg24le1.h"
#include "main.h"
#include "nRF24L01.h"

/*
================================================================================
SPI_Exchange :
Exchange a byte via the MCU
input : dt, the byte to be sent
Output : The byte read from the slaver
================================================================================
*/
INT8U SPI_ExchangeByte( INT8U dt )
{
SPIRDAT = dt;
while( !( SPIRSTAT & 0x02 ) );
return SPIRDAT;
}
//RF interrupt
INT8U RecFlag = 0;
void RF_IRQ( void ) interrupt INTERRUPT_RFIRQ
{
INT8U i = L01_ReadIRQSource( );

if( i & ( 1<<RX_DR ) ) //Received data
{
RecFlag = 1;
}
if( i & ( 1<<TX_DS ) ) //Send data OK
{
}
if( i & ( 1<<MAX_RT ) ) //Send data fail
{
}
L01_ClearIRQ( IRQ_ALL );
}
/*
================================================================================
UART_Init:
Initialize the UART
input : BaudIndex, the index of the baudrate of the UART, 0-7, 1200-115200
Output : None
================================================================================
*/
code unsigned int UART_BAUD_TBL[7] = { 607, 816, 920, 972, 998, 1011, 1015 };
//0----6,,,--> 1200, 2400, 4800, 9600, 19200, 38400, 57600
void UART_Init( unsigned char BaudIndex )
{
IEN0 &= ~( 1<<4 ); //Disable UART0 interrupt while initializeing
S0CON = ( 1<<6 ) | ( 1<<4 ); //MODE1, Enable receive
ADCON = 0x80; //Enable baudrate generator
PCON |= 0x80; //mode1
S0RELL = UART_BAUD_TBL[BaudIndex];
S0RELH = UART_BAUD_TBL[BaudIndex] >> 8;
IEN0 |= ( 1<<4 ); //Enable interrupt
P0DIR |= ( 1<<6 ); //P0.6, RXD, set as input
P0DIR &= ~( 1<<5 ); //P0.5, TXD, set as output
}
unsigned char TX_OK = 0;
static void UART0_ISR( void ) interrupt INTERRUPT_UART0
{
if( S0CON & ( 1<<1 ) )
{
//TX ok
S0CON &= ~( 1<<1 );
TX_OK = 1;
}
else if( S0CON & ( 1<<0 ) )
{
//RX ok
S0CON &= ~( 1<<0 );
}
}

void UART0_SendBuff( unsigned char *buff, unsigned char size )
{
while( size -- )
{
TX_OK = 0;
S0BUF = *buff ++;
while( TX_OK == 0 );
}
TX_OK = 0;
}
void UART0_SendStr( char* str )
{
UART0_SendBuff( ( unsigned char* ) str, strlen( str ) );
}
int main( void )
{
INT16U itmp;
INT8U reclen, buff[32];

CLKCTRL = ( CLKCTRL | 0x80 ) & ~0x08;
P0DIR = 0;
UART_Init( 3 ); //9600, 8, N, 1

RFCON = 0x07;
RFCE = 0;
RFCKEN = 1; // Æô¶¯RFʱÖÓ
RF = 1; // ÔÊÐíRFÖжÏ
for( itmp = 0; itmp < 30000; itmp ++ );

L01_Init( ); //Initialize the internal 24L01P
L01_SetRXMode( ); //Set as TX mode
L01_FlushTX( );
L01_FlushRX( );
L01_ClearIRQ( IRQ_ALL );

RFCE = 1;

EA = 1;
UART0_SendStr( "nRF24LE1 RX test start!\r\n" );

while( 1 )
{
while( RecFlag == 0 );
RecFlag = 0;
reclen = L01_ReadRXPayload( buff );
L01_FlushTX( );
L01_FlushRX( );
UART0_SendBuff( buff, reclen );
P0 ^= ( 1<<2 ) | ( 1<<3 ) | ( 1<<4 );
}
}
joselalupa
 
Posts: 32
Joined: Tue Aug 12, 2014 4:44 pm

Re: getting errors in eclipse

Postby brennen » Mon Dec 21, 2015 5:07 pm

How are you physically programming the LE1 (as in, how are you flashing the LE1)?
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: getting errors in eclipse

Postby joselalupa » Mon Dec 21, 2015 8:23 pm

I am using this to flash it
http://www.canton-electronics.com/nrf24 ... p-547.html

With this board i check the lvds blaine when the message is received
http://www.canton-electronics.com/24g-n ... p-760.html
joselalupa
 
Posts: 32
Joined: Tue Aug 12, 2014 4:44 pm

Re: getting errors in eclipse

Postby brennen » Mon Dec 21, 2015 8:43 pm

I'm not familiar with your development boards or you programmer, so I can't really help you with this part.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

PreviousNext

Return to 8051 Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron