Content originally posted in LPCWare by jab on Fri Sep 30 06:57:29 MST 2011
Hello,
We have built our own custom cortex M0 development board and we are having some issues with writing code for it.
The bootloader works fine, we can get the part number etc off the chip so we know the chip is working.
Our code is simple, it just toggles the pull up resistor enable on a GPIO pin (a very minimal test). We have this pin then connected to an oscilloscope.
CODE BELOW
----------------------------------------
/*
===============================================================================
Name : main.c
Author :
Version :
Copyright : Copyright (C)
Description : main definition
===============================================================================
*/
#ifdef __USE_CMSIS
#include "LPC122x.h"
#endif
#include <cr_section_macros.h>
#include <NXP/crp.h>
// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
// TODO: insert other include files here
// TODO: insert other definitions and declarations here
#define __DISABLE_WATCHDOG 1
int main(void) {
unsigned long Test1 = 0;
LPC_IOCON->PIO0_0 = Test1;
// TODO: insert code here
while(1) {
if (Test1 == 0)
{
Test1 = 16;
}
else
{
Test1 = 0;
}
LPC_IOCON->PIO0_0 = Test1;
}
return 0 ;
}
All we do is toggle bit 4 in the IOCON register for GPIO0_0.
We have LPCxpresso generating a hex file which we then download using flash magic, here are the post build commands.
arm-none-eabi-objcopy -O binary ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin; checksum -v ${BuildArtifactFileBaseName}.bin; arm-none-eabi-objcopy -I binary ${BuildArtifactFileBaseName}.bin -O ihex ${BuildArtifactFileBaseName}.hex;
The strange thing is, if I just disable the pullup once the line pulls low correctly, but it doesnt toggle. I have also tried to use the IO properly, writing to the out register but that didnt work, figured this program was easier to post.
The system is configured to use the internal RC osc.
Thanks for your help in advance, I feel like I have been banging my head against a brick wall for several hours!
Julian