Posted by DrE on April 14, 2003, 12:03:21, in reply to "Re: DA Channel 2 and 3" void InitTPU5(void); void main(void) // Enable TPU // Enable all DAC channels InitTPU5(); while(1) void InitTPU5(void) void DelayMs(unsigned short Delay)
194.131.190.3
Not sure what is wrong with your code.
Try the code below.
It works with no problems on the system I am using.
/*
**-----------------------------------------------------------------------
**
** main.c - contains C entry point main()
**
** This file was generated by HEW IAR Icch8 project generator
**
**-----------------------------------------------------------------------
*/
#include "ioh82633.h"
void DelayMs(unsigned short);
{
unsigned char Count;
// Enable DAC's
MSTPCRA &= ~0x04; // Bit 2
MSTPCRC &= ~0x20; // Bit 5
MSTPCRA &= ~0x20; // Bit 5
DACR01 |= 0xe0; // DAC0 & DAC1 enabled
DACR23 |= 0xe0; // DAC0 & DAC1 enabled
{
for(Count = 0; Count < 255; Count++)
{
DADR0 = Count;
DADR1 = (0xff - Count);
DADR2 = Count;
DADR3 = (0xff - Count);
DelayMs(10); // 10ms delay (roughly)
}
}
}
{
// TPU 5
TPU_TCR5 = 0x20 | 0x00 | 0x03; // Clear on CM/IC A
// Count on rising edge
// Clock source clk/64
TPU_TMDR5 = 0; // Normal mode
TPU_TIOR5 = 0; // Outputs disabled
TPU_TIER5 = 0x40; // Interrupts disabled
TPU_TGR5A = 288; // @ 18.432 MHz (& clk/64) a value of
// 288 gives a CM time of 1ms
// (1 / 18.432M ) * 64 = 3.472us
// 1m / 3.472 = 288
TPU_TGR5B = 0;
TPU_TCNT5 = 0;
}
{
unsigned short Count;
for(Count=0; Count<Delay; Count++)
{
TPU_TSTR |= 0x20; // Start TPU5
while((TPU_TSR5 & 0x01 ) != 0x01); // wait for Compare Match flag(~1ms)
TPU_TSTR &= ~0x20; // Stop TPU5
TPU_TSR5 &= ~0x01; // Clear Flag
}
}
Message Thread:
![]()
« Back to thread
Evaluation Kit Support
Renesas Evaluation Boards are intended for evaluation of Renesas microprocessors only, not as development tools.