Using PCMSK, PCINTn,GIMSK,PCINT_D_vect,PCINT_B_vect in the ATTiny2313A

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How to use   PCMSK, PCINTn,GIMSK,PCINT_D_vect,PCINT_B_vect in the ATTiny2313A for interrupts on edge  for    PINB  () PIND

 

How to use   GIMSK |=(1<<PCIE ); or   0b00101000;  or  GIMSK |= (1<<PCIE0)|(1<<PCIE2); in Atmel studio 4.19 with C toolchain ?

Unable to install Windows6.1-KB2999226-x64.msu, Windows6.1-KB2670838-x64.msu if I use as-installer-7.0.1931-full.exe from Microchip's site  . The toolchain may be with bug in  the iotn2313a.h (unable to view and setup PCMSK0<PCMSK1,PCMSK2, GIMSK |= (1<<PCIE0)|(1<<PCIE2); ) .

How to use PCINT_D_vect,PCINT_B_vect for ATTiny 2313A . 

Example : program for controlling  the tape recorder  Mayak-232  (in the attacment).

Unable to view PCMSK0:
  PCMSK   |=(1<<PCINT6); (bit6)?  fix?
  PCMSK  |=(1<<PCINT7);  (bit7)?  fix?

How to use 

PCMSK2 |=(1<<PCINT2);
PCMSK2 |=(1<<PCINT3);
PCMSK2 |=(1<<PCINT4);
PCMSK2 |=(1<<PCINT5);
PCMSK2 |=(1<<PCINT6);

 for interrupts on PIND ?

ISR (PCINT_D_vect)
{
cli();

SelectMode(PIN_CTRL);

return;
}
  

ISR(PCINT_B_vect)
{

ParseAutoStop();
return;
}

 

void INIT_Int()

{

 

 

 

 

 GIMSK = 0b00111000;     ?

 PCMSK = 0b01111100;

 

 //GIMSK |=(1<<PCIE ); //0b00101000; // (1<<PCIE0)|(1<<PCIE2);

 

// GIMSK |= (1<<INT1);

/*

    interrupt on INT0 pin falling edge 

   ISC00=0; ISC01=1 The falling edge of INT0 generates an interrupt request

  ISC10=1; ISC11=1 The rising edge of INT1 generates an interrupt request

   MCUCR |= (1<<ISC01) ;//| (1<<ISC00);

   MCUCR|=(1<<ISC11)|(0<<ISC10);

    

  //MCUCR &= ~(1 << ISC01);

  //MCUCR |= (1 << ISC00);

 

 PCINT0-PCINT7=PB0-PB7  PCMSK0

 PCINT8-PCINT10=PA0-PA2 PCMSK1

 PCINT11-PCINT17= PD0-PD6 PCMSK2 

   

 

 

*/

 

/*

0x20 (0x40) PCMSK0 PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0 53

0x04 (0x24) PCMSK1 – – – – – PCINT10 PCINT9 PCINT8

0x05 (0x25) PCMSK2 – PCINT17 PCINT16 PCINT15 PCINT14 PCINT13 PCINT12 PCINT11

 

*/

 

 

  //MCUCR |= (1<<ISC01); 

  //MCUCR &= (1<<ISC00); 

 

  PCMSK   |=(1<<PCINT6);

  PCMSK  |=(1<<PCINT7);

 

 

PCMSK2 |=(1<<PCINT2);

PCMSK2 |=(1<<PCINT3);

PCMSK2 |=(1<<PCINT4);

PCMSK2 |=(1<<PCINT5);

PCMSK2 |=(1<<PCINT6);

 

 

  //PCMSK  |=PIN2_CTRL_IntMask;//(1<<PINB6);

 

 

 

 

  

 

 

 

return;

}

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I install as-installer-7.0.1931-full.exe ,  I view  error message  : 

 

Please install the following Windows Updates:

Essential Windows Updates: 1

KB2999226: https://support.microsoft.com/en...

Optional Windows Updates(Data Visualizer Rendering): 1

KB2670838: https://support.microsoft.com/en...

 

  (or) 

Consider updating Windows from Control Panel -> Windows Update.

If I install as6installer-6.0.1996.exe ,  some components are not installed , could not run program.

How to fix bug in the toolchain?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ISR(PCINT_B_vect)
 

That doesn't sound like a valid vector name?? Normally they are PCINT1_vect etc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, where to start--

 

-- Learn ow to use the Code tags, <> on the formatting toolbar, to preserve formatting when posting source code.

-- The next thing you will hear is something about 4.10, and why are you using a toolchain that old?

-- In fact, was that model released when 4.19 was in vogue?

 

What exact is the problem?  Start with one...perhaps those that give you syntax errors.  As it is, there is so much going on in the discussion it is hard to tell.  What do you think are the typos in the chip-include file?  What warnings do you get when you build?  ESPECIALLY about misspelled interrupt vector names.  What makes you think the names you posted in the source code are correct?  That isn't what is show here https://www.microchip.com/webdoc... or anywhere else that I know of.

 

What is your schematic?  Do you really have all of the I/O pins tied to non-floating levels?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do yourself a favor ans start with >>one<< pin.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah, apologies, apparently the 2313 vectors have dual names...

D:\atmel_avr\avr8-gnu-toolchain\avr\include\avr>grep _vect iotn2313*.h | grep _VECT
iotn2313.h:#define INT0_vect                        _VECTOR(1)
iotn2313.h:#define INT1_vect                    _VECTOR(2)
iotn2313.h:#define TIMER1_CAPT_vect             _VECTOR(3)
iotn2313.h:#define TIMER1_COMPA_vect            _VECTOR(4)
iotn2313.h:#define TIMER1_OVF_vect                      _VECTOR(5)
iotn2313.h:#define TIMER0_OVF_vect                      _VECTOR(6)
iotn2313.h:#define USART_RX_vect                        _VECTOR(7)
iotn2313.h:#define USART_UDRE_vect                      _VECTOR(8)
iotn2313.h:#define USART_TX_vect                        _VECTOR(9)
iotn2313.h:#define ANA_COMP_vect                        _VECTOR(10)
iotn2313.h:#define PCINT_vect                   _VECTOR(11)
iotn2313.h:#define TIMER1_COMPB_vect            _VECTOR(12)
iotn2313.h:#define TIMER0_COMPA_vect            _VECTOR(13)
iotn2313.h:#define TIMER0_COMPB_vect            _VECTOR(14)
iotn2313.h:#define USI_START_vect                       _VECTOR(15)
iotn2313.h:#define USI_OVERFLOW_vect            _VECTOR(16)
iotn2313.h:#define EEPROM_READY_vect            _VECTOR(17)
iotn2313.h:#define WDT_OVERFLOW_vect            _VECTOR(18)
iotn2313a.h:#define INT0_vect      _VECTOR(1)  /* External Interrupt Request 0 */
iotn2313a.h:#define INT1_vect      _VECTOR(2)  /* External Interrupt Request 1 */
iotn2313a.h:#define TIMER1_CAPT_vect      _VECTOR(3)  /* Timer/Counter1 Capture Event */
iotn2313a.h:#define TIMER1_COMPA_vect      _VECTOR(4)  /* Timer/Counter1 Compare Match A */
iotn2313a.h:#define TIMER1_OVF_vect      _VECTOR(5)  /* Timer/Counter1 Overflow */
iotn2313a.h:#define TIMER0_OVF_vect      _VECTOR(6)  /* Timer/Counter0 Overflow */
iotn2313a.h:#define USART0_RX_vect      _VECTOR(7)  /* USART, Rx Complete */
iotn2313a.h:#define USART_RX_vect      _VECTOR(7)  /* alias */
iotn2313a.h:#define USART0_UDRE_vect      _VECTOR(8)  /* USART Data Register Empty */
iotn2313a.h:#define USART_UDRE_vect      _VECTOR(8)  /* alias */
iotn2313a.h:#define USART0_TX_vect      _VECTOR(9)  /* USART, Tx Complete */
iotn2313a.h:#define USART_TX_vect      _VECTOR(9)  /* alias */
iotn2313a.h:#define ANA_COMP_vect      _VECTOR(10)  /* Analog Comparator */
iotn2313a.h:#define PCINT0_vect      _VECTOR(11)  /* Pin Change Interrupt Request 0 */
iotn2313a.h:#define PCINT_B_vect      _VECTOR(11)  /* alias */
iotn2313a.h:#define TIMER1_COMPB_vect      _VECTOR(12)  /*  */
iotn2313a.h:#define TIMER0_COMPA_vect      _VECTOR(13)  /*  */
iotn2313a.h:#define TIMER0_COMPB_vect      _VECTOR(14)  /*  */
iotn2313a.h:#define USI_START_vect      _VECTOR(15)  /* USI Start Condition */
iotn2313a.h:#define USI_OVERFLOW_vect      _VECTOR(16)  /* USI Overflow */
iotn2313a.h:#define EEPROM_Ready_vect      _VECTOR(17)  /* EEPROM Ready */
iotn2313a.h:#define WDT_OVERFLOW_vect      _VECTOR(18)  /* Watchdog Timer Overflow */
iotn2313a.h:#define PCINT1_vect      _VECTOR(19)  /* Pin Change Interrupt Request 1 */
iotn2313a.h:#define PCINT_A_vect      _VECTOR(19)  /* alias */
iotn2313a.h:#define PCINT2_vect      _VECTOR(20)  /* Pin Change Interrupt Request 2 */
iotn2313a.h:#define PCINT_D_vect      _VECTOR(20)  /* alias */

(but only in the 2313A header)

Last Edited: Thu. Jul 19, 2018 - 02:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Bug  with

 

GIMSK |=  0b00101000;   (unable to view in the simulator )   

 

may be fixed if use  external compiler  ( https://stackoverflow.com/questi... ).

 

Attachment(s): 

Last Edited: Thu. Jul 19, 2018 - 03:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A prototype of the circuit diagram (functional diagram) of the module  for programming ( may be with UART  support):

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

void INIT_Int()

{

 

 

 

 

 GIMSK = 0b00110000;       // I can not view bit 4 in the IDE , I use manual setup  

 PCMSK2  =  0b01111100;  //interrupts mask for   PDn

 PCMSK = 0b11000000;      //interrupts mask for   PBn  . Is it PCMSK0 ?

 

  /// MCUCR |= (1<<ISC01); 

  // MCUCR &= (1<<ISC00); 

  // MCUCR |= (1<<ISC11); 

  // MCUCR &= (1<<ISC10); 

 

 

/*

 

 PCINT0-PCINT7=PB0-PB7  PCMSK0

 PCINT8-PCINT10=PA0-PA2 PCMSK1

 PCINT11-PCINT17= PD0-PD6 PCMSK2 

   

 

 

*/

 

/*

0x20 (0x40) PCMSK0 PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0 53

0x04 (0x24) PCMSK1 – – – – – PCINT10 PCINT9 PCINT8

0x05 (0x25) PCMSK2 – PCINT17 PCINT16 PCINT15 PCINT14 PCINT13 PCINT12 PCINT11

 

*/

 

 

return;

}

 

/*
PCINT0_vect is called PCINT_B_vect 
PCINT1_vect is called PCINT_A_vect 
PCINT2_vect is caleld PCINT_D_vect 
*/
 

ISR (PCINT_D_vect)
{
cli();

SelectMode(PIN_CTRL);

return;
}
  

ISR(PCINT_B_vect)
{

  ParseAutoStop();
return;
}

 

 

 

It  may work with WinAVR-20100110 as the compiler .

 

 

How to use  interrupt on edge of changing of signal on PD2-PD5, PD6 ,PB6,PB7 ,as in the INT0?

 

/*

    interrupt on INT0 pin falling edge 

   ISC00=0; ISC01=1 The falling edge of INT0 generates an interrupt request

  ISC10=1; ISC11=1 The rising edge of INT1 generates an interrupt request

   MCUCR |= (1<<ISC01) ;//| (1<<ISC00);

   MCUCR|=(1<<ISC11)|(0<<ISC10);

   A low pin should trigger the interrupt

  MCUCR &= ~(1 << ISC01);

  MCUCR |= (1 << ISC00);

*/

 

/*
PCINT0_vect is called PCINT_B_vect 
PCINT1_vect is called PCINT_A_vect 
PCINT2_vect is caleld PCINT_D_vect 
*/
 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you miss, in #4, theusch wrote:
-- Learn how to use the Code tags, <> on the formatting toolbar, to preserve formatting when posting source code.

See Tip #1 for illustrated instructions.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Jul 19, 2018 - 05:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An alternative circuit with  modifyed  pins definition :

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Files of the  project with fixed bugs. It works.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rpz3598 wrote:
It works.

Jolly good!

 

Now plesae mark the solution - see Tip #5

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...