Skip to content

Instantly share code, notes, and snippets.

@piense
Created December 24, 2019 06:10
Show Gist options
  • Save piense/65e50b0d9a44edfef098f7ea6705bf49 to your computer and use it in GitHub Desktop.
Save piense/65e50b0d9a44edfef098f7ea6705bf49 to your computer and use it in GitHub Desktop.
PIC32MX675F256H
#include <p32xxxx.h>
#include <stdint.h>
#include <sys/kmem.h>
uint8_t __attribute__((coherent)) buf[200];
void main()
{
uint32_t i;
for(i = 0;i<200;i++)
{
buf[i] = 65;
}
// Configure BAUD rate
U1BRG = 4; //4 Mbps assuming an 80Mhz PB clock
U1MODESET = 1 << _U1AMODE_BRGH_POSITION; // BRGH = 1
//U1ASTAbits.UTXISEL = 1;
U1MODESET = 1 << _U1AMODE_ON_POSITION; // Enable UART
U1STASET = 1 << _U1STA_UTXEN_POSITION; // TX enabled
IFS0bits.U1TXIF = 0;
DMACONSET = 0x8000; //Enable DMA
DCH0SSA = KVA_TO_PA(&buf); // Source Address
DCH0SSIZ = 200; //Source size
DCH0DSIZ = 1; // Destination size
DCH0CSIZ = 1; //Cell Size
DCH0ECONbits.CHSIRQ = _UART1_TX_IRQ;
DCH0ECONSET = 16; //UART IRQ & enable IRQ cell trigger
DCH0DSA = KVA_TO_PA(&U1TXREG); // Destination Address
DCH0CONSET = 0x80; //Enable DMA Channel
while(1)
{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment