Forum: Mikrocontroller und Digitale Elektronik MSSP Interrupt


von Alex X. (behindi)


Lesenswert?

Hallo

Ich hab nen Problem und komm einfach nich weiter.
wäre super wenn mir jemand einen Ratschlag geben könnte

Ich versuche bei dem PIC18F4685 einen Interrupt über das SPI Interface 
auszulösen.
Der PIC arbeitet als Slave und soll einen Interrupt auslösen wenn ein 
Byte angekommen ist. Das Problem ist, dass kein Interrupt ausgelöst 
wird.

Hier das Programm (mit C18 Compiler)
1
#include "p18f4685.h"
2
#include "delays.h"
3
#include "math.h"
4
5
void Ports_Init(void);
6
void SPI_slave_init(void);
7
void Interrupts_Enable(void);
8
void ISH(void);
9
void ISL(void);
10
11
#pragma code IVH = 0x08    // Interrupt-Vektor fuer hohe Priori
12
void IVH(void)
13
{
14
  _asm              
15
    goto ISH        // Interrupt Service Routine fuer HP
16
  _endasm
17
}
18
19
void main (void)
20
{
21
    Ports_Init();
22
    SPI_slave_init();
23
    Interrupts_Enable();
24
25
    LATD=0x01;
26
    while(1);
27
}
28
29
void Ports_Init(void)
30
    {
31
    LATD=0x00;      // LED + master SCK1 & SO
32
    TRISD=0x00;
33
34
    ADCON1=0x0f;
35
    CMCON = 0x07;      // Analog Comparators off
36
37
    LATB=0x00;
38
    TRISB=0xff;         // Dip schalter
39
40
    TRISCbits.TRISC3=1;     // CKL input
41
    TRISCbits.TRISC4=1;     // SDI input
42
    TRISCbits.TRISC5=0;     // SDO output
43
44
    TRISAbits.TRISA5=1;     // SS!  input
45
    }
46
47
void SPI_slave_init(void)
48
    {
49
    SSPCON1bits.SSPEN = 1;  // Enable MSSP
50
    SSPCON1bits.CKP = 0;    // IDLE is low level
51
    SSPCON1bits.SSPM3 = 0;
52
    SSPCON1bits.SSPM2 = 1;
53
    SSPCON1bits.SSPM1 = 0;
54
    SSPCON1bits.SSPM0 = 0;  // Slave Mode, SCK and \SS enabled
55
56
    SSPSTATbits.SMP = 0;    // Always cleared in Slave Mode
57
    SSPSTATbits.CKE = 0;   
58
59
    PIR1bits.SSPIF = 0;     // Just in case, clear Interrupt Flag
60
    }
61
62
void Interrupts_Enable(void)                                 
63
{
64
    RCONbits.IPEN = 0;          // Interrupt-Prioritaeten deaktiviert
65
    INTCONbits.GIEL = 1;        // LP-Interrupts aktiviert
66
    PIE1bits.SSPIE=1;           // enable the MSSP Interrunpt
67
    IPR1bits.SSPIP=1;           // MSSP high priority
68
    INTCONbits.GIEH = 1;        // Interrupts global aktiviert
69
70
}
71
72
#pragma interrupt ISH
73
void ISH(void)
74
{
75
        LATD=0xff;
76
        PIR1bits.SSPIF = 0;
77
}
78
79
#pragma interrupt ISL
80
void ISL(void)
81
{}

Danke für jede Hilfe:)

Grüße
Alex

von Alex X. (behindi)


Lesenswert?

was vileicht noch wichtig ist , dass ich SS auf Masse lege und die CKL 
Impule nur mit einem Dipschlter realisiert haben.
Das sollte aber keinen Einfluss haben oder?

Danke

von Alex X. (behindi)


Lesenswert?

So jetz is Wochenende,

wenn von euch jemand schon mal mit MSSP als Interruptquelle gearbeitet 
hat wäre super wenn mir jemand weiterhelfen könnte, danke:)

gruß
alex

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.