Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Impedance_Fast_Circuitry by
Diff: pdb.cpp
- Revision:
- 51:43143a3fc2d7
- Parent:
- 50:33524a27e08c
--- a/pdb.cpp Sat Jan 31 19:46:00 2015 +0000 +++ b/pdb.cpp Sat Jan 31 20:17:58 2015 +0000 @@ -1,7 +1,11 @@ #include "pdb.h" -Serial debug2(USBTX,USBRX); +//Serial debug2(USBTX,USBRX); + +/* The PDB is setup to run continuous (when enabled) so it will + * periodically trigger the ADCs to sample and trigger DMA2 to + * save the quadrature angle. The PDB can be started and stopped. */ void pdb_init() { // initialize the Programmable Delay Block @@ -32,8 +36,27 @@ | PDB_SC_MULT(0) // Multiplication factor 20 for the prescale divider for the counter clock | PDB_SC_CONT_MASK // Contintuous, rather than one-shot, mode | PDB_SC_LDOK_MASK; // Need to ok the loading or it will not load certain regsiters! - //PDB0_SC &= ~PDB_SC_CONT_MASK; // enable one-shot mode for debugging. + //NVIC_SetVector(PDB0_IRQn, (uint32_t)&PDB0_IRQHandler); + //NVIC_EnableIRQ(PDB0_IRQn); +} + +void PDB0_IRQHandler() { + +} + +void pdb_start() { + PDB0_SC |= PDB_SC_PDBEN_MASK; // PDB enabled + PDB0_SC |= PDB_SC_SWTRIG_MASK; // enable software trigger (start the PDB) +} + +void pdb_stop() { + //PDB0_SC &= ~PDB_SC_CONT_MASK; // change to one-shot mode, so pdb will stop after current count + PDB0_SC &= ~PDB_SC_PDBEN_MASK; // PDB disabled +} + + +/* debug2.printf("PDB0_SC: %08x\r\n",PDB0_SC); debug2.printf("PDB0_MOD: %08x\r\n",PDB0_MOD); debug2.printf("PDB0_CNT: %08x\r\n",PDB0_CNT); @@ -54,24 +77,4 @@ debug2.printf("PDB0_PO0DLY: %08x\r\n",PDB0_PO0DLY); debug2.printf("PDB0_PO1DLY: %08x\r\n",PDB0_PO1DLY); debug2.printf("PDB0_PO2DLY: %08x\r\n\n",PDB0_PO2DLY); - - //NVIC_SetVector(PDB0_IRQn, (uint32_t)&PDB0_IRQHandler); - //NVIC_EnableIRQ(PDB0_IRQn); -} - - -void PDB0_IRQHandler() { - //switcher = !switcher; - -} - - -void pdb_start() { - PDB0_SC |= PDB_SC_PDBEN_MASK; // PDB enabled - PDB0_SC |= PDB_SC_SWTRIG_MASK; // enable software trigger (start the PDB) -} - -void pdb_stop() { - //PDB0_SC &= ~PDB_SC_CONT_MASK; // change to one-shot mode, so pdb will stop after current count - PDB0_SC &= ~PDB_SC_PDBEN_MASK; // PDB disabled -} \ No newline at end of file + */ \ No newline at end of file