EmbDev.net

Forum: µC & Digital Electronics OCtopus direct programming


Author: guest (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi,


I know that the octopus is coming with its own firmware and its own 
software libraries to control it from the PC.

Nevertheless my goal is to first gather some experience with the 
ATmega128 that it contains. Therefore I loaded my own AVR program 
instead of the firmware.

Actually the program does not behave as I am expecting: My program is 
just be able to send characters and to receive some. To see the result I 
write the bits "PORTC = 0xEF;" which drives the LEDs.

My Code was successfully charged on the Octopus Board.

For the application I have a Hterm on PC instaliert.

The Octopus Device ist recognized on my Pc. Because on System>System 
Control>Hardware-Manager  I can see "LibUSB-Win32Devices" --> "OtopusUSB 
Interface Converter and I/O Extension".

although that, when I write the name of the port "LibUSB-Win32Devices" 
or "OtopusUSB Interface Converter and I/O Extension" on my Hterm, he 
doesn't recognize it. I don't know witch Port the Octopus have. Or I 
must proceed in another art.


Please help me I am a beginner and want to work mit Octopus.

thanks for reading.
#ifndef F_CPU
#warning "F_CPU was not defined yet, now make up with 4000000"
#define F_CPU 4000000L                    // Systemtakt in Hz - define as  long>> Without errors in the computation 
#endif


#define BAUD 9600L
#define UBRR_VAL ((F_CPU+BAUD * 8)/(BAUD*16)-1)     //clever round
#define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1)))         //real baud rate
#define BAUD_ERROR ((BAUD_REAL*1000)/BAUD-1000)     //Error per thousand


#if ((BAUD_ERROR>10)||(BAUD_ERROR<-10))
#error Systematic error in the baud rate more than 1% and thus too high!
#endif


#include <avr/io.h>
#include <stdlib.h>
#include <inttypes.h>
#include <util/delay.h>


//for USART0
void USART_Init(void) 
{
  
  UBRR0H = (unsigned char)(UBRR_VAL>>8);            // Set baud rate
  UBRR0L = (unsigned char)UBRR_VAL;
  
  UCSR0B |= (1<<RXEN)|(1<<TXEN);                    // Enable receiver and transmitter
  
  UCSR0C =  (1<<UCSZ00)|(1<<UCSZ01);    // Set frame format: 8data, 1stop bit        

}//end USART_Init()

void USART_Putc(unsigned char c)
{
    while (!(UCSR0A & (1<<UDRE0))); // Do nothing until data have been transmited 
    
    UDR0 = c;                      // Put data into Buffer, sends the data
    _delay_ms(10);   
}//end USART_Putc()

//function which send a String Through uart
void USART_Puts (char *string)
{
    while( *string != '\0' )    //as long as *string != '\0' so unlike the "stringer end-character"
    {  
        USART_Putc(*string);
        string++;
    }
}//end USART_Puts()


unsigned char UART_Getc()
{    
    while( !(UCSR0A & (1<<RXC)) );    // Do nothing until data have been recieved and is ready to be read from UDR 
    
    return UDR0;                        //Get and receive data from Buffer
}//end USART_Receive()


int main(void) 
{
    DDRC = 0xFF;                        // define as output 
    USART_Init();
    USART_Puts("\r\n");
    USART_Puts("Messung gestartet:");            // receives data
    
   unsigned char received;
  
  while(1) 
  {
        received = UART_Getc();                   // sends data
         PORTC = 0xEF
      if(received == 0x0D)                   // = ENTER-Taste
             USART_Puts("\r\n");
     else 
    {
    USART_Puts("\r\n");
        USART_Putc(received );
        if(   (received >= 0x61 && received <= 0x7A)     //a      bis      z
           || (received >= 0x41 && received <= 0x5A)       //A     bis     Z 
           || (received >= 0x30 && received <= 0x39)      //0      bis     9 
           || (received == 0x20)                       ) //<SPACE>
       
        USART_Puts("\r\n");
    USART_Putc(received);
    USART_Puts("\r\n");
     }
  }
   return 0;                     
} //end main()

Author: R. Freitag (rfr)
Posted on:

Rate this post
0 useful
not useful
There is an octopus forum here---> http://forum.embedded-projects.net/
where your questions will be seen and answerded by octopus experts.

so long

Robert

Author: guest (Guest)
Posted on:

Rate this post
0 useful
not useful
Thank,

I posted my problem there. It has a long time but never reponces.
And when I peruse the "Octopus" forum, I find there only problems which
were never answered.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.