Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | I need help combining two programs as one

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

I need help combining two programs as one - truelove_30 - May 4 13:17:45 2008

#include "c:\egnu110\include\hcs12.h"
#include "c:\egnu110\include\delay.c"
//This program is Flashing of two Leds
main (void)
{
char led_tab[4] = {0x80,0x20,0x20,0x80};
char i;
DDRB = 0xFF; /* configure port B for output */
DDRJ |= 0x02; /* configure PJ1 pin for output (needed for
Dragon12 board only) */
PTJ &= 0xFD;
while (1){
for (i = 0; i < 4; i++) {
PORTB = led_tab[i];
delayby100ms(2);
}
}
return 0;
}

The second program is below:

#include "c:\egnu110\include\hcs12.h"
#define hi_freq 1250 /* delay count for 1200 Hz */
#define lo_freq 5000 /* delay count for 300 Hz */
int main (void)
{
unsigned int oc5cnt;

TSCR1 = 0x90; /* enable TCNT with fast timer flag clear */
TSCR2 = 0x03; /* set TCNT prescaler to 8 */
TIOS |= 0x20; /* enable OC5 */
TCTL1 = 0x04; /* set OC5 pin action to toggle */
while (1) {
oc5cnt = 200; /* one sound lasts for 1/3 seconds */
do {
TC5 = TCNT + lo_freq; /* start an OC5 operation */
while(!(TFLG1 & 0x20)); /* wait until OC5 matches */
} while (--oc5cnt);

oc5cnt = 800; /* one sound lasts for 1/3 seconds */
do {
TC5 += hi_freq; /* start an OC5 operation for high
freq */
while(!(TFLG1 & 0x20));
} while (--oc5cnt);
}
return 0;
}

------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: I need help combining two programs as one - BobG...@aol.com - May 4 14:12:37 2008

You could rename each main to be a subroutine... the first one could be
'ledflash' and the second 'beep' and write a new main that calls ledflash() and
beep() in a loop

In a message dated 5/4/2008 1:17:59 P.M. Eastern Daylight Time,
t...@yahoo.com writes:

#include "c:\egnu110\include\hcs12.h"
#include "c:\egnu110\include\delay.c"
//This program is Flashing of two Leds
main (void)
{
char led_tab[4] = {0x80,0x20,0x20,0x80};
char i;
DDRB = 0xFF; /* configure port B for output */
DDRJ |= 0x02; /* configure PJ1 pin for output (needed for
Dragon12 board only) */
PTJ &= 0xFD;
while (1){
for (i = 0; i < 4; i++) {
PORTB = led_tab[i];
delayby100ms(2);
}
}
return 0;
}

The second program is below:

#include "c:\egnu110\include\hcs12.h"
#define hi_freq 1250 /* delay count for 1200 Hz */
#define lo_freq 5000 /* delay count for 300 Hz */
int main (void)
{
unsigned int oc5cnt;

TSCR1 = 0x90; /* enable TCNT with fast timer flag clear */
TSCR2 = 0x03; /* set TCNT prescaler to 8 */
TIOS |= 0x20; /* enable OC5 */
TCTL1 = 0x04; /* set OC5 pin action to toggle */
while (1) {
oc5cnt = 200; /* one sound lasts for 1/3 seconds */
do {
TC5 = TCNT + lo_freq; /* start an OC5 operation */
while(!(TFLG1 & 0x20)); /* wait until OC5 matches */
} while (--oc5cnt);

oc5cnt = 800; /* one sound lasts for 1/3 seconds */
do {
TC5 += hi_freq; /* start an OC5 operation for high
freq */
while(!(TFLG1 & 0x20));
} while (--oc5cnt);
}
return 0;
}

------------------------------------

Yahoo! Groups Links

**************Wondering what's for Dinner Tonight? Get new twists on family
favorites at AOL Food.
(http://food.aol.com/dinner-tonight?NCID=aolfod00030000000001)
[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: I need help combining two programs as one - "smith.jeff28" - May 4 14:40:03 2008

If you look at the Dragon12 "C" examples, it shows how to generate
tones, it plays a song, using interrupts.

This is how it should be done.
------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Re: I need help combining two programs as one - Jerome Williams - May 4 15:47:59 2008

I am trying to understand: The following example is a sketletal outline of a two file C program that makes use of external variables:
In file 1:
exterm int xy;
extern long arr[]:
main ()
{
}
void foo (int abc){...}
long soo (void) {...}
In file 2:
int xy;
long arr[100];

----- Original Message ----
From: smith.jeff28
To: 6...@yahoogroups.com
Sent: Sunday, May 4, 2008 2:39:56 PM
Subject: [68HC12] Re: I need help combining two programs as one
If you look at the Dragon12 "C" examples, it shows how to generate
tones, it plays a song, using interrupts.

This is how it should be done.

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )