Previous 15994 Revisions Next

r6543 Saturday 5th December, 2009 at 11:28:05 UTC by Tim Schuerewegen
[GP32] Corrected timer frequency.
[src/mess/drivers]gp32.c

src/mess/drivers/gp32.c
r6542r6543
107107
108108static UINT32 s3c240x_clkpow_regs[0x18/4];
109109
110UINT32 cpu_get_fclk( int reg)
110static UINT32 s3c240x_get_fclk( int reg)
111111{
112112   UINT32 data, mdiv, pdiv, sdiv;
113113   data = s3c240x_clkpow_regs[reg]; // MPLLCON or UPLLCON
114114   mdiv = (data >> 12) & 0xFF;
115115   pdiv = (data >>  4) & 0x3F;
116116   sdiv = (data >>  0) & 0x03;
117   return (UINT32)((float)((mdiv + 8) * 12000000) / (float)((pdiv + 2) * (1 << sdiv)));
117   return (UINT32)((double)((mdiv + 8) * 12000000) / (double)((pdiv + 2) * (1 << sdiv)));
118118}
119119
120UINT32 cpu_get_hclk( int reg)
120/*
121static UINT32 s3c240x_get_hclk( int reg)
121122{
122123   switch (s3c240x_clkpow_regs[5] & 0x3) // CLKDIVN
123124   {
124      case 0 : return cpu_get_fclk( reg) / 1;
125      case 1 : return cpu_get_fclk( reg) / 1;
126      case 2 : return cpu_get_fclk( reg) / 2;
127      case 3 : return cpu_get_fclk( reg) / 2;
125      case 0 : return s3c240x_get_fclk( reg) / 1;
126      case 1 : return s3c240x_get_fclk( reg) / 1;
127      case 2 : return s3c240x_get_fclk( reg) / 2;
128      case 3 : return s3c240x_get_fclk( reg) / 2;
128129   }
129130   return 0;
130131}
132*/
131133
132UINT32 cpu_get_pclk( int reg)
134static UINT32 s3c240x_get_pclk( int reg)
133135{
134136   switch (s3c240x_clkpow_regs[5] & 0x3) // CLKDIVN
135137   {
136      case 0 : return cpu_get_fclk( reg) / 1;
137      case 1 : return cpu_get_fclk( reg) / 2;
138      case 2 : return cpu_get_fclk( reg) / 2;
139      case 3 : return cpu_get_fclk( reg) / 4;
138      case 0 : return s3c240x_get_fclk( reg) / 1;
139      case 1 : return s3c240x_get_fclk( reg) / 2;
140      case 2 : return s3c240x_get_fclk( reg) / 2;
141      case 3 : return s3c240x_get_fclk( reg) / 4;
140142   }
141143   return 0;
142144}
r6542r6543
220222   const int mux_shift[] = { 0, 4, 8, 12, 16};
221223   if (ctrl_bits & 1)   // timer start?
222224   {
223      UINT32 prescaler, mux, freq, cnt, cmp, tps;
225      UINT32 prescaler, mux, freq, cnt, cmp;
226      double hz;
224227      logerror( "starting timer %d\n", timer);
225228      prescaler = (s3c240x_timer_regs[0] >> prescaler_shift[timer]) & 0xFF;
226229      mux = (s3c240x_timer_regs[1] >> mux_shift[timer]) & 0x0F;
227      freq = cpu_get_pclk( 1) / (prescaler + 1) / mux_table[mux];
230      freq = s3c240x_get_pclk( 1) / (prescaler + 1) / mux_table[mux];
228231      cnt = s3c240x_timer_regs[count_reg+0] & 0xFFFF;
229232      if (timer != 4)
230233         cmp = s3c240x_timer_regs[count_reg+1] & 0xFFFF;
231234      else
232235         cmp = 0;
233      tps = freq * (cnt - cmp + 1);
234//      logerror( "TIMER %d - FCLK=%d HCLK=%d PCLK=%d prescaler=%d div=%d freq=%d cnt=%d cmp=%d tps=%d\n", timer, cpu_get_fclk( 1), cpu_get_hclk( 1), cpu_get_pclk( 1), prescaler, mux_table[mux], freq, cnt, cmp, tps);
236      hz = (double)((prescaler + 1) * mux_table[mux]) / (cnt - cmp + 1);
237//      logerror( "TIMER %d - FCLK=%d HCLK=%d PCLK=%d prescaler=%d div=%d freq=%d cnt=%d cmp=%d hz=%f\n", timer, s3c240x_get_fclk( 1), s3c240x_get_hclk( 1), s3c240x_get_pclk( 1), prescaler, mux_table[mux], freq, cnt, cmp, hz);
235238      if (ctrl_bits & 8) // auto reload
236239      {
237         timer_adjust_periodic( s3c240x_timers[timer], ATTOTIME_IN_HZ( tps), timer, ATTOTIME_IN_HZ( tps));
240         timer_adjust_periodic( s3c240x_timers[timer], ATTOTIME_IN_HZ( hz), timer, ATTOTIME_IN_HZ( hz));
238241      }
239242      else
240243      {
241         timer_adjust_oneshot( s3c240x_timers[timer], ATTOTIME_IN_HZ( tps), timer);
244         timer_adjust_oneshot( s3c240x_timers[timer], ATTOTIME_IN_HZ( hz), timer);
242245      }
243246   }
244247   else   // stopping is easy
r6542r6543
371374   smc.busy = 0;
372375}
373376
374UINT8 smc_read( running_machine *machine)
377static UINT8 smc_read( running_machine *machine)
375378{
376379   const device_config *smartmedia = devtag_get_device( machine, "smartmedia");
377380   UINT8 data;
r6542r6543
380383   return data;
381384}
382385
383void smc_write( running_machine *machine, UINT8 data)
386static void smc_write( running_machine *machine, UINT8 data)
384387{
385388//   logerror( "smc_write %08X\n", data);
386389   if ((smc.chip) && (!smc.read))
r6542r6543
404407   }
405408}
406409
407void smc_update( running_machine *machine)
410static void smc_update( running_machine *machine)
408411{
409412   if (!smc.chip)
410413   {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team