In het verleden heb ik diverse siemens microcontrollers gebruikert inclusief seriele communicatie via een max232 chip.
Ik heb zojuist mijn ATmega8515 op mijn Max232 chip aangesloten zoals het moet, de MAX232 chip aan de sub9 connector en deze aan de PC.
Ik start Hyperterminal op en verwacht constant tekst te zien verschijnen, er gebeurt echter niets.
Waar kan ik het beste meten om te vinden wat fout gaat? Ligt het aan Hyperterminal? Deze staat maar mijn weten juist ingesteld.
//ICC-AVR application builder : 2/2/04 8:12:09 PM
// Target : M8515
// Crystal: 16.000Mhz
#include <iom8515v.h>
#include <macros.h>
#include <stdio.h>
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0x00;
PORTB = 0xFF;
DDRB = 0x00;
PORTC = 0xFF;
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
PORTE = 0x07;
DDRE = 0x00;
}
//UART0 initialisation
// desired baud rate: 9600
// actual: baud rate:9615 (0.2%)
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = 0x86;
UBRRL = 0x67; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x18;
}
//call this routine to initialise all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
uart0_init();
MCUCR = 0x00;
EMCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialised
}
void main(void)
{
init_devices();
while(1)
{
printf("A\n");
}
}Jonathan
"Theorie is alleen te rechtvaardigen als 'n vorm van praktijk. De praktijk staat niet terecht voor 't hooggerechtshof van de theorie" (Stephan Toulmin)
sytse
Euh......
Ik heb hier een voorbeeldje uit de Examples van CodeVision AVR. Ik weet niet of je dit zo in jou compiler kunt gebruiken zonder het aan te passen. Maar misschien heb je er wat aan.
/*********************************************
This program was produced by the
CodeWizardAVR V1.24.0 Evaluation
Automatic Program Generator
© Copyright 1998-2003 HP InfoTech s.r.l.
http://www.hpinfotech.ro
e-mail:office@hpinfotech.ro
Project :
Version :
Date : 16-12-2003
Author : Freeware, for non-commercial use only
Company :
Comments:
Chip type : AT90S8515
Clock frequency : 3,686400 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 128
*********************************************/
#include <90s8515.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
interrupt [UART_RXC] void uart_complete(void)
{
PORTC = UDR;
}
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0x00;
UCR=0x18;
UBRR=0x17;
ACSR=0x80;
while (1)
{
}
}
Ps. Die smiley's in de code zijn best irri
Ik heb net wat pin meetingen gedan...
V5 - PIN14 = 13V
V5 - PIN13 = 5V
Spanning op verschilt van -8 tot +5
Iemand enig idee wat er aan de hand is want dit lijkt me NIET normaal...
[Bericht gewijzigd door Parcye op ]
Heb nu het volgende gedaan:
Interupt laten gerereren als er data verzonden is en als er data ontvangen is...
Als ik data stuur, wordt de intrupt actief en knippert de led, dit duid er dus op dat er wel data wordt verzonden, of komt deze interupt ook als de data niet goed verzonden zou zijn?
New Status...
Als ik TX van de uC aftap via weerstand naar LED, brand de LED continu.
Als ik TXout lijn van MAX232 aftap via weerstand naar LED, knippert de LED
Dit lijkt op een juiste signaal, voor als ik 'A' op de output zet.