Any help with Embedded systems programming

Status
Not open for further replies.

iyaoyas818

Junior Member
Jul 23, 2011
1
0
0
Need help with some problems I am having in Embedded systems programming


Assuming that the PIC18F8680 microcontroller is running with a 40-MHz oscillator, write a sequence of C statements to generate a 10-kHz digital waveform with an 80% duty cycle.


Assuming that the PIC18F8680 microcontroller is running with a 32-MHz oscillator, write a sequence of C statements to generate an 8-kHz digital waveform with a 75% duty cycle.


Write a sequence of C statements to configure the USART of the PIC18 microcontroller to operate with the following parameters:
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]Baud rate set to 38,400
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]Serial port enabled
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]Transmission enabled
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]Reception enabled
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]Asynchronous mode selected
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]High-speed mode selected
[FONT=MS Mincho,MS Mincho][FONT=MS Mincho,MS Mincho]• [/FONT][/FONT]8-bit operation for both transmission and reception

I need to do this in C language.
Any help would be appriciated. I dont know where to start.
 
Last edited by a moderator:

Cogman

Lifer
Sep 19, 2000
10,286
147
106
This looks like homework.

First, make sure you know what a duty cycle is
http://en.wikipedia.org/wiki/Duty_cycle

Now, given that your system runs at 40-MHz and 32-MHz, I'm guessing the teacher wants you to loop x number of times and count the number of clocks per instruction to get the 10 kHz and 8 kHz signal.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
How do you get to the point where problems like this are assigned but you have no idea where to even start? It's not like this is a day 1 homework assignment.

"Students, welcome to Introduction to Automatic Data Processing 103. For your first assignment, program channel 1 of the 8254 programmable timer to interrupt at 1200 hz, and chain an interrupt handler to provide the original system frequency to the original handler. You have one hour."
 

Cogman

Lifer
Sep 19, 2000
10,286
147
106
How do you get to the point where problems like this are assigned but you have no idea where to even start? It's not like this is a day 1 homework assignment.

"Students, welcome to Introduction to Automatic Data Processing 103. For your first assignment, program channel 1 of the 8254 programmable timer to interrupt at 1200 hz, and chain an interrupt handler to provide the original system frequency to the original handler. You have one hour."

I could feasibly see it as a day one assignment for embedded systems. After all, it really is a basic concept, especially since, unlike their desktop counterparts, the clock speed and number of cycles for a give instruction are basically constant.

The problem isn't TOO difficult, especially if something like Computer Architecture is a prerequisite for the class.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
The first two parts of generating a square wave is really easy.

For the UART configuration, you're gonna need to dig into the datasheet and learn about all the registers and then write the necessary values to the necessary registers to configure the UART.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I could feasibly see it as a day one assignment for embedded systems. After all, it really is a basic concept, especially since, unlike their desktop counterparts, the clock speed and number of cycles for a give instruction are basically constant.

The problem isn't TOO difficult, especially if something like Computer Architecture is a prerequisite for the class.

Then you must be assuming some prior programming knowledge, in which case the guy should at least have an idea where to begin.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Then you must be assuming some prior programming knowledge, in which case the guy should at least have an idea where to begin.

If its the first assignment of the semester, it might be a baseline knowledge homework to test if you should really be in the class. We did something similar in the embedded systems courses that I TA'ed for.
 
Status
Not open for further replies.