programming language c using atmega328p

Go To Last Post
69 posts / 0 new

Pages

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm talking about this part of the task.

The robo1 () function is implemented - you just have to use it.

Implement the program for Robot 1 which:

Executes the function robo1 () periodically with a period of 1 sec. --------How is a function executed periodically with a period of 1 sec?

At the end of the function execution, it sends the return value of the function via UART to Robot 2 (assuming that robots 1 and 2 are connected to each other via a serial communication line

 

through UART) to implement the periodic execution to be used interrupt Service and Output Compare Timer interrupt in normal mode (free running)------------------How?

 

Select the parameters for communication via UART with the maximum speed for communication which support the controller in question. Implement parity bit for error checking.
The use of Arduino IDE functions is not allowed and the use of delay () functions is not allowed. The oscillator frequency is 4 Mhz----------------------------------------------------------How?

roboti1.c

unsigned char robo1(void);

 

int init_robo1 (void) {

 

 

}
int main (void) {

 

 

 

}

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This parti

 

 

The robo1 () function is implemented - you just have to use it.

Implement the program for Robot 1 which:

Executes the function robo1 () periodically with a period of 1 sec ------------------------Si ekzekutohet nje funskionin ne menyre periodike me nje periode prej 1 sec?

At the end of the function execution, it sends the return value of the function via UART to Robot 2 (assuming that robots 1 and 2 are connected to each other via a serial communication line through UART) to implement the periodic execution to be used interrupt Service and Output Compare Timer interrupt in normal mode (free running)------------------------------------------How?

 

 

Select the parameters for communication via UART with the maximum speed for communication which support the controller in question. Implement parity bit for error checking.
The use of Arduino IDE functions is not allowed and the use of delay () functions is not allowed. The oscillator frequency is 4 Mhz-------------------------------------------------------How?

 

roboti1.c

unsigned char robo1(void);

 

int init_robo1 (void) {

 

 

}
int main (void) {

 

 

 

}

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Metro1 wrote:
This is my goal to continue my specialization in server programming after being accepted to the University, but I must first pass the exam in embedded.

A-Ha this thread has developed a new twist since I last posted.

 

Can we assume you have zero interest in embedded programming ? This is totally understandable, I used to work amongst programmers who were adept with AngularJS but couldn't program AVR for toffee. (even when given Arduino)

 

Here's a radical thought; what happens if you simply fail the embedded section of the entrance exam but ace those sections that are pertinent to back-end server coding.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Metro1 wrote:

Please guys
Will you help me solve the first part of the task that has to do with the robot1?
I'm tired of trying but not understanding the part with UART and TIMER.

I thought you would give me the motivation to continue learning for the entrance exam in Computer Science.

I already showed you the high level of the structure for this in #29. All that remains is to add the detail to that. That will involve programming UART and timer. You say you are "tired of trying"? Well I guess it depends how desperately you want to join this course. But consider this: you actually state that this is the paper from a previous year. So assuming you work away at this and learn about timer and UART and then you find that in "this years paper" they actually set a task involving ADC and SPI how are you going to get on with that? The bottom line is that you probably need to have done the entire course that the other entrants have done. Learned about ADC, I2C, Comparator, timer (CTC and PWM), UART, SPI and all the other AVR peripherals that they likely were taught about. Then, when this years exam turns out to be I2C and PWM you will be prepared.

 

Or are you really hoping they just set the same robo1()/robo2() question every year? It's a bit of gamble!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Metro1 wrote:
How is a function executed periodically with a period of 1 sec?

That is answered for you:

to implement the periodic execution to be used interrupt Service and Output Compare Timer interrupt in normal mode (free running)-

So have you tried googling those terms?

 

http://www.lmgtfy.com?q=Timer+Output+Compare+Interrupt+Service

 

 

Metro1 wrote:
the controller in question

Which controller is that?

 

Add its model number to your google search ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Jul 27, 2020 - 02:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please guys
Will you help me solve the first part of the task that has to do with the robot1? 

We wouldn't want to give you the wrong advice, so you must list everything you have learned so far about embedded programming, with a brief explanation and example of each concept.

I'm tired of trying but not understanding the part with UART and TIMER.   IF YOU ARE TIRED OF TRYING THAT DOESN'T BODE WELL

I thought you would give me the motivation to continue .  SORRY IT DOESN'T WORK THAT WAY

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

So if you needed to update a web page once a second, how would you do that?

show the code needed please!

 

jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello can you tell me if this first part of the task I have given is good

 

#include <avr/io.h>
#include<avr/interrupt.h>
#define F_OSC 4000000
#DEFINE PRESCALER 1024
#define TCS_PER_INTERVAL(F_OSC/PRESCALER)
#define BAUD 9600
#DEFINE MYUBERR (F_OSC/16/BAUD-1)
voltile unsigned int sec;
volatile unsigned char value;

ISR(TIMER1_COMPA_vect){
    sex++;
    OCRIA+= TICS_PER_INTERVAL'
    value=init_robo1();
    usartWrite(value);
}
void usartWrite(unsigned char data)
{
    

while(!(UCSR0A &(1<< UDRE0)));
UDR0=data;

}
void init(void)
{
    
//UART
UBRROH =MYUBRR>>8;
UBRROL= MYUBRR & 0x00FF;
UCSR0B = 1<<TXEN0;
UCSROC |=(1<<UPM00)|(1<<UPM01);
UCSR0C |=(1<<UCSZ00)|(1<<UCSZ01);
UCSR0C |=0<<USBS0

//TIMER

TCCR1A|=1<<COM1A0;
TCCR1B|=(1<<CS12)|(1<<CS10);
OCR1A=TICS_PER_INTERVAL;
TIMSKI|=1<<OCIE1A;

sei();

int init_robo1(void)
{
    sec=0;
    init();
    while(1){

    }
}

}

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello can you tell me if this first part of the task I have given is good

 

#include <avr/io.h>
#include<avr/interrupt.h>
#define F_OSC 4000000
#DEFINE PRESCALER 1024
#define TCS_PER_INTERVAL(F_OSC/PRESCALER)
#define BAUD 9600
#DEFINE MYUBERR (F_OSC/16/BAUD-1)
voltile unsigned int sec;
volatile unsigned char value;

ISR(TIMER1_COMPA_vect){
    sex++;
    OCRIA+= TICS_PER_INTERVAL'
    value=init_robo1();
    usartWrite(value);
}
void usartWrite(unsigned char data)
{
    

while(!(UCSR0A &(1<< UDRE0)));
UDR0=data;

}
void init(void)
{
    
//UART
UBRROH =MYUBRR>>8;
UBRROL= MYUBRR & 0x00FF;
UCSR0B = 1<<TXEN0;
UCSROC |=(1<<UPM00)|(1<<UPM01);
UCSR0C |=(1<<UCSZ00)|(1<<UCSZ01);
UCSR0C |=0<<USBS0

//TIMER

TCCR1A|=1<<COM1A0;
TCCR1B|=(1<<CS12)|(1<<CS10);
OCR1A=TICS_PER_INTERVAL;
TIMSKI|=1<<OCIE1A;

sei();

int init_robo1(void)
{
    sec=0;
    init();
    while(1){

    }
}

}

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello can you tell me if this first part of the task I have given is good

 

#include <avr/io.h>
#include<avr/interrupt.h>
#define F_OSC 4000000
#DEFINE PRESCALER 1024
#define TCS_PER_INTERVAL(F_OSC/PRESCALER)
#define BAUD 9600
#DEFINE MYUBERR (F_OSC/16/BAUD-1)
voltile unsigned int sec;
volatile unsigned char value;

ISR(TIMER1_COMPA_vect){
    sex++;
    OCRIA+= TICS_PER_INTERVAL'
    value=init_robo1();
    usartWrite(value);
}
void usartWrite(unsigned char data)
{
    

while(!(UCSR0A &(1<< UDRE0)));
UDR0=data;

}
void init(void)
{
    
//UART
UBRROH =MYUBRR>>8;
UBRROL= MYUBRR & 0x00FF;
UCSR0B = 1<<TXEN0;
UCSROC |=(1<<UPM00)|(1<<UPM01);
UCSR0C |=(1<<UCSZ00)|(1<<UCSZ01);
UCSR0C |=0<<USBS0

//TIMER

TCCR1A|=1<<COM1A0;
TCCR1B|=(1<<CS12)|(1<<CS10);
OCR1A=TICS_PER_INTERVAL;
TIMSKI|=1<<OCIE1A;

sei();

int init_robo1(void)
{
    sec=0;
    init();
    while(1){

    }
}

}

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've been pointed to the Tips in my signature already - Tip #1 shows you how to properly post source code.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Put comments in the code which describe what you think the code should be doing.

 

Do just one thing at a time; eg, timer first; UART next.

 

 

 

Metro1 wrote:
sex++;

laugh laugh laugh laugh 

 

Go on - you clearly haven't even tried to compile it yourself.

 

You could use the Simulator in Atmel Studio to see how it runs (although it runs an order of magnitude slower than real time) ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hahhahahhaah noo sex++

sec++

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

So if you needed to update a web page once a second, how would you do that?

At it's simplest:

function myreloader() {
  location.reload();
}

setTimeout(myreloader, 1000);

Which partly illustrates my point above - these web guys just cant be a**ed with F_CPU or configuring registers.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like to mention that when you set up one of those network servers, they tend to have serial interfaces (e.g., UARTs at least that was how telecom machines were), they did not have screens or keyboards. So if you ever need to provision such a server to develop on, then the knowledge of how a UART works would be handy. The R-Pi has figured out a way around the provisioning problem, but that in itself is a topic.

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone
I thank you for the advice you have given me to solve the task, by practicing those tips I have managed to solve the task.

This task was not a task that is set in practice or school task, I was practicing some of the exercises that I found on the Internet and I wanted to practice.

Thanks again for all the tips.

M.K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lockout Padlock

 

Just say'in ...

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Lockout Padlock

 

Just say'in ...

 

JC

 

great idea

 

jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Pages

Topic locked