Moin, ich verbringe hier inzwischen Stunden damit Informationen zusammen zu tragen wie man den DMA Controller vewenden kann. Vielleicht kann ja hier einer nen Stück weiter helfen. im PIC24 FRM DMA Manual findet sich: CHSEL<5:0>: DMA Channel Trigger Selection bits These bits select one of 64 possible DMA triggers to be connected to the channel’s input. Generally, these are the device-level interrupts; the list of triggers corresponds to the reverse-order natural-priority interrupt list. Refer to the specific device data sheet for the mapping of bit values to peripherals. Im PIC24FJ128GA206 Datenblatt findet sich auf Seite 97 Eine Vector Tabelle, welche Addressen sind hier wie zu verwenden? Ich suche UART2 TX Interrupt
Hallo, ich habe den mit PIC24 schon erfolgreich verwendet - für ein Display. Ich lade mal das C-File hoch. Das ist so: Es gibt einen Speicherbereich im RAM der auf die SPI gschrieben wird. Hier werden zwei DMA-Kanäle verwendet. Ein Kanal schreibt einen Speicherbreich auf das SPI-TX-Register. Der zweite entleert den RX-Buffer. Ich glaube mich zu erinnern, dass das nötig war. dma_spi_init(); setzt die DMA-Kanäle auf dma_spi_tranfer() Tritt die Geschichte los. Den Inhalt für CHSEL (Trigger source) findet man im Datenblatt. Bei meinem PIC (PIC24FJ128GC006) ist das unter "DMA TRIGGER SOURCES". DMA ist ein sehr schönes Feature, wenn man CPU-Last sparen muss.
ui, vielen Dank schonmal, ich probier das morgen aus. Wie man CHSE einstellt habe ich im Datenblatt gefunden, da gibts ne extra Tabele für.
ok, ich konnte die Finger nicht von lassen, hab es ausbprobiert. Geht jetzt bei mir auch. Ich schick mal den finalen code von mir für UART2, vielleicht braucht es jemand anderes hier auch mal.
1 | void __attribute__((__interrupt__, auto_psv)) _DMA0Interrupt(void) |
2 | {
|
3 | IFS0bits.DMA0IF = 0; //clear flag |
4 | Nop(); |
5 | }
|
6 | |
7 | uint8_t txdata[20] = "1Y3Y567890qwertyuiop"; |
8 | |
9 | //UART setup
|
10 | U2MODE = 0; // disable UART |
11 | U2BRG = DBRG; |
12 | U2MODEbits.BRGH = 1; |
13 | U2MODEbits.UARTEN = 1; // enable UART |
14 | U2STAbits.UTXEN = 1; //Enable TX PIN AFTER U2MODE!! |
15 | |
16 | U2STAbits.UTXISEL0 = 1; |
17 | U2STAbits.UTXISEL1 = 0; |
18 | |
19 | |
20 | //CLear IF Flags
|
21 | IFS1bits.U2RXIF = 0; |
22 | IFS1bits.U2TXIF = 0; |
23 | |
24 | |
25 | |
26 | //DMA
|
27 | DMACONbits.DMAEN = 1; //enable DMA |
28 | DMACONbits.PRSSEL = 1; //round robin sceme |
29 | DMASRC0=(unsigned short int)&txdata; |
30 | DMADST0 = (volatile unsigned int)&U2TXREG; |
31 | |
32 | //DMA0 channel configuration (Transmit)
|
33 | DMACH0bits.CHEN = 0; //disable DMA channel 0 for the moment |
34 | DMACH0bits.BYTE = 1; //Transfer is bytewise |
35 | DMACH0bits.TRMODE = 0b00; //one shot tranfer |
36 | DMACH0bits.DAMODE = 0b00; //destination address is fixed |
37 | DMACH0bits.SAMODE = 0b01; //source address is incremented on event |
38 | |
39 | |
40 | |
41 | // Send Data from Array1 to UART2
|
42 | |
43 | // UART 2 Transmitter DMA0 is configured to use the UART?s receive interrupt as a trigger.
|
44 | DMAINT0bits.CHSEL = 0b100000; |
45 | DMAINT0bits.DONEIF = 0; //reset done interrupt flag |
46 | DMAL = 0; |
47 | DMAH = 0xFFFF; |
48 | |
49 | // Transfer now:
|
50 | DMACNT0=10; |
51 | |
52 | // DMA Interrupt
|
53 | IPC1bits.DMA0IP = 2; //This is a low priority interrupt |
54 | IFS0bits.DMA0IF = 0; //reset Flag |
55 | IEC0bits.DMA0IE = 1; //enable Interrupt |
56 | |
57 | // ENable DMA
|
58 | DMACH0bits.CHEN = 1; //Enable TX DMA |
59 | |
60 | //enable trigger source interrupt
|
61 | IFS1bits.U2TXIF = 1; //make sure, flag is set for first transfer |
62 | |
63 | //reset bits
|
64 | DMAINT0bits.DONEIF = 0; |
65 | |
66 | //kick off data transfer by generating a request
|
67 | DMACH0bits.CHREQ = 1; |
68 | |
69 | Nop(); |
70 | |
71 | |
72 | while(1); |
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.