[En-Nut-Discussion] Create new platform
Michał Gryko
odk at odkurzacz.org
Sun Oct 24 12:55:22 CEST 2010
Hi, I'm designing own platform as a student project. It's based on
ATmega 128. I want to use NutOS on it. Hardware is ready and I used
simple non NutOS app to test it. Here it is:
#include <avr/io.h>
// define what pins the LEDs are connected to.
#define LED PC0
#define F_CPU 16000000
// Some macros that make the code more readable
#define output_low(port,pin) port &= ~(1<<pin)
#define output_high(port,pin) port |= (1<<pin)
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)
void delay_ms(uint8_t ms) {
uint16_t delay_count = F_CPU / 17560;
volatile uint16_t i;
while (ms != 0) {
for (i=0; i != delay_count; i++);
ms--;
}
}
int main(void) {
set_output(DDRC, LED);
while (1) {
output_high(PORTC, LED);
delay_ms(200);
output_low(PORTC, LED);
delay_ms(200);
}
}
It's working as intended (led blinks), but when I moved to NutOS with this:
#include <sys/timer.h>
int main(void)
{
sbi(DDRC, 0);
for(;;){
cbi(PORTC, 0);
NutSleep(500);
sbi(PORTC, 0);
NutSleep(500);
}
return 0;
}
build is ok, target mcu is atmega128, but nothing happens (led is
dead). Tried on ethernut-4.8.7 and 4.9. Board has no external memory.
Any ideas what could be wrong?
More information about the En-Nut-Discussion
mailing list