mirror of https://github.com/ARMmbed/mbed-os.git
Added a load of debug lines
Basically this outputs a load of stuff to the serial port. I'm just using this to get an idea of where the error lies within the code...pull/17/head
parent
9097bf7f55
commit
84a76cd8d8
|
@ -25,6 +25,9 @@ void wait_ms(int ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_us(int us) {
|
void wait_us(int us) {
|
||||||
|
printf("Here!\r\n");
|
||||||
uint32_t start = us_ticker_read();
|
uint32_t start = us_ticker_read();
|
||||||
|
printf("next\r\n");
|
||||||
while ((us_ticker_read() - start) < us);
|
while ((us_ticker_read() - start) < us);
|
||||||
|
printf("End\r\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,25 @@
|
||||||
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of RAM
|
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of RAM
|
||||||
|
|
||||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||||
|
printf("X\r\n");
|
||||||
int i;
|
int i;
|
||||||
|
printf("0a\r\n");
|
||||||
// Space for dynamic vectors, initialised to allocate in R/W
|
// Space for dynamic vectors, initialised to allocate in R/W
|
||||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||||
|
printf("1a\r\n");
|
||||||
// Copy and switch to dynamic vectors if first time called
|
// Copy and switch to dynamic vectors if first time called
|
||||||
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
|
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
|
||||||
|
printf("2a\r\n");
|
||||||
uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
|
uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
|
||||||
|
printf("Old_vectors: %i\r\n", old_vectors);
|
||||||
for(i = 0; i < NVIC_NUM_VECTORS; i++) {
|
for(i = 0; i < NVIC_NUM_VECTORS; i++) {
|
||||||
|
printf("3a\r\n");
|
||||||
vectors[i] = old_vectors[i];
|
vectors[i] = old_vectors[i];
|
||||||
}
|
}
|
||||||
|
printf("4a\r\n");
|
||||||
LPC_SYSCON->SYSMEMREMAP = 0x1; // Remaps 0x0-0x1FF FLASH block to RAM block
|
LPC_SYSCON->SYSMEMREMAP = 0x1; // Remaps 0x0-0x1FF FLASH block to RAM block
|
||||||
}
|
}
|
||||||
|
printf("5a\r\n");
|
||||||
// Set the vector
|
// Set the vector
|
||||||
vectors[IRQn + 16] = vector;
|
vectors[IRQn + 16] = vector;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,26 @@
|
||||||
int us_ticker_inited = 0;
|
int us_ticker_inited = 0;
|
||||||
|
|
||||||
void us_ticker_init(void) {
|
void us_ticker_init(void) {
|
||||||
|
printf("0\r\n");
|
||||||
|
|
||||||
if (us_ticker_inited) return;
|
if (us_ticker_inited) return;
|
||||||
us_ticker_inited = 1;
|
us_ticker_inited = 1;
|
||||||
|
|
||||||
|
printf("1\r\n");
|
||||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10); // Clock TIMER_1
|
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10); // Clock TIMER_1
|
||||||
|
printf("2\r\n");
|
||||||
uint32_t PCLK = SystemCoreClock;
|
uint32_t PCLK = SystemCoreClock;
|
||||||
|
printf("3\r\n");
|
||||||
US_TICKER_TIMER->TCR = 0x2; // reset
|
US_TICKER_TIMER->TCR = 0x2; // reset
|
||||||
|
printf("4\r\n");
|
||||||
uint32_t prescale = PCLK / 1000000; // default to 1MHz (1 us ticks)
|
uint32_t prescale = PCLK / 1000000; // default to 1MHz (1 us ticks)
|
||||||
|
printf("5\r\n");
|
||||||
US_TICKER_TIMER->PR = prescale - 1;
|
US_TICKER_TIMER->PR = prescale - 1;
|
||||||
|
printf("6\r\n");
|
||||||
US_TICKER_TIMER->TCR = 1; // enable = 1, reset = 0
|
US_TICKER_TIMER->TCR = 1; // enable = 1, reset = 0
|
||||||
|
printf("7\r\n");
|
||||||
NVIC_SetVector(US_TICKER_TIMER_IRQn, (uint32_t)us_ticker_irq_handler);
|
NVIC_SetVector(US_TICKER_TIMER_IRQn, (uint32_t)us_ticker_irq_handler);
|
||||||
|
printf("8\r\n");
|
||||||
NVIC_EnableIRQ(US_TICKER_TIMER_IRQn);
|
NVIC_EnableIRQ(US_TICKER_TIMER_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +50,8 @@ uint32_t us_ticker_read() {
|
||||||
if (!us_ticker_inited)
|
if (!us_ticker_inited)
|
||||||
us_ticker_init();
|
us_ticker_init();
|
||||||
|
|
||||||
|
printf("Hello!!!\r\n");
|
||||||
|
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ int main() {
|
||||||
led = 1;
|
led = 1;
|
||||||
printf("LED on\r\n");
|
printf("LED on\r\n");
|
||||||
wait(0.5);
|
wait(0.5);
|
||||||
|
printf("After wait\r\n");
|
||||||
led = 0;
|
led = 0;
|
||||||
wait(0.5);
|
wait(0.5);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue