Hi everybody,
I’m quite new in developing Software for Software for the STR912FW44 from ST.
I’m using an Olimex Development Board (STR-E912) wich also contains a CAN Controller.
I was able to find an example from Hitex [here wich implements sending
a CAN Message, but was for the STR9-comstick. However, I managed to compile the Software (later with a blinking LED to confirm the Software is working) an
flash it to the STR9. The Problem is: There is nothing on the CAN. On Problem should be, that the CAN-TX is on a GPIO-Pin, wich is not connected to the phyisical
CAN-Interface of the Board. But I was not able to Measure any change (using an oscilloscpe) anywhere on the Board. In the end i was switching on the LED, when
starting to send something and switch it of, when finished. I noticed, that it was taking longer, when i uncommented the sending off a CAN Message.
Now i have no clue where to search next, since i can measure nothing. I would be really happy, if someone could help me out.
I used arm-elf-gcc 3.4.4 under Debian Testing for compiling.
Cheers
Christoph
/* Main Program */
int main(void)
{
// stuff for blinking
// turn on clock for GPIO port 9
SCU_PCGR1 = BIT23;
// take port out of reset
SCU_PRR1 = BIT23;
P9DIR = 1; // make LSB an output
//config für CAN
SCU_Configuration();
CAN_Configuration();
while (1)
{
P9LSB = 1; // on
//for (inner=0;inner < 5;inner++);
//ReallyLongDelay();
CAN->sMsgObj[0].DA1R = 0x22 ;
/* Set the message valid bit */
/* Update informations from interface registers */
CAN->sMsgObj[0].CRR = 2;
P9LSB = 0; // off
ReallyLongDelay();
}
}
void ReallyLongDelay() {
long inner;
for (inner=0;inner < 1000;inner++);
}
void SCU_Configuration (void)
{
// Initialise STR912 CPU
// All SCU-PCGR1 peripherals clocks are disabled by default in START912.S
// Do not clear any bits in SCU_PCGR0 as this is the SRAM, VIC etc!
SCU->PCGR1 |= (SCU->PCGR1 & ~0x00080000) | 0x00080000 ; /* Clock for GPIO5 is b19 */
SCU->PRR1 &= ~0x00080000 ; /* Force reset */
SCU->PRR1 |= 0x00080000 ; /* Release reset */
SCU->GPIOOUT[5] = 0x0008 ; /* P5.0 = alt input 1, P5.1 = alt output 2 */
SCU->GPIOIN[5] = 0x03 ; /* P5.0 = alt input 1 */
SCU->GPIOTYPE[5] = 0x0000 ; /* All output pins are push-pull */
GPIO5->DDR = 0x02 ; /* No simple IO used */
/* Initialise CAN Module */
/* Enable CAN peripheral clocks */
SCU->PCGR1 |= (SCU->PCGR1 & ~0x00000400) | 0x00000400 ; /* Clock for CAN is b10 */
SCU->PRR1 &= ~0x00000400 ; /* Force reset */
SCU->PRR1 |= 0x00000400 ; /* Release reset */
/* Set APBDIV to get 48MHz PCLK */
SCU->CLKCNTR = (SCU->CLKCNTR & ~0x00000180) | 0x00000080 ; /* PCLK = Fmstr/2 = 48MHz */
}
void CAN_Configuration (void)
{
/* Initialise CAN0 for full (part2.0B) CAN operation */
CAN->CR = 0x00000001; /* init and config change enable */
CAN->CR = 0x000000C1;
CAN->BRPR = 0x00000000; /* Clear the extended BRP */
// CAN->BTR = 0x00003AC5; /* Set bit rate to 500K: Tq = PCLK/24 = 0.5us, TSEG1 = 9, TSEG2 = 4, SJW = 4 */
CAN->BTR = 0x0000755F; /* Set bit rate to 100K */
CAN->CR = 0x00; /* End CAN initialisation mode */
CAN->sMsgObj[0].CMR = 0x00B3;
/* Reset the MSGVAL bit to enable ID, DIR and DLC change */
CAN->sMsgObj[0].A2R = 0;
/* Setup the identifier information */
CAN->sMsgObj[0].A1R = 0x00;
CAN->sMsgObj[0].A2R = 0x04;
/* Setup type information */
CAN->sMsgObj[0].A2R |= CAN_A2R_DIR|CAN_A2R_XTD;
/* Setup data bytes */
CAN->sMsgObj[0].MCR = 0x8980 | 1;
CAN->sMsgObj[0].A2R |= CAN_A2R_MSGVAL;
}