I am trying to work with PIN Change Interrupt PCINT2
The below code is not working
If I connect a 5V input on PCINT2 I see no output printed
[code]Enable Pcint2
'Pcmsk = &B00001000
Set Pcie0
On Pcint2 Pin_change_isr
Pin_change_isr:
Print "Pin Changed"
Return[/code]
I am getting error if I use following code. My BASCOM version is 2.0.7.5
[code]Pcmsk = &B00000100 // error
Set GIMSK.PCIE0 //error[/code]
Please help
Thank you
[b][color=red](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b][/color]
↧
BASCOM-AVR : PIN Change Interrupt BASCOM Version 2.0.7.5 : NEWTOPIC
↧
BASCOM-AVR Old versions : PIN Change Interrupt BASCOM Version 2.0.7.5 : REPLY
which processor do you use?
did you checked the PCINT_CHANGE.bas sample from the samples folder?
↧
↧
BASCOM-AVR : TIMER1 as Monostable Multivibrator ? : NEWTOPIC
Hi,
Please can anybody help with this:
I would like to have Timer1 as adjustable monostable multivibrator. Processor Attiny4313, Xtal 16MHz. The trigerring input INT1, output OC1B with active high level. Setting time 0-10ms.
Thanks
[b:a38f384a87][color=red:a38f384a87](BASCOM-AVR version : 2.0.7.8 )[/b:a38f384a87][/color:a38f384a87]
↧
BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY
Here is a short program that when the "Home" is removed puts random text on LCD
Regards Paul
[code:1:3b8562a2d8]
$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 57600
$hwstack = 100 ' default use 32 for the hardware stack
$swstack = 100 'default use 10 for the SW stack
$framesize = 100 'default use 40 for the frame space
Config I2cdelay = 40
$lib "i2c_twi.lib" 'hardware i2c/TWI
Config Twi = 100000
$lib "bl_Lcd_i2c.lib" ' AN #118 library from Kent
Backlight_on Alias &H08
Backlight_off Alias &H00
Const Pcf_d4 = 4
Const Pcf_d5 = 5
Const Pcf_d6 = 6
Const Pcf_d7 = 7
Const Pcf_rs = 0
Const Pcf_rw = 1
Const Pcf_e1 = 2
Dim B As Byte
Dim A As Byte
Dim _lcd_e As Byte
Dim Backlight As Byte
_lcd_e = 128
Const Pcf8574_lcd = &H4E 'Defines the address of the I/O expander for LCD
Config Scl = Portc.5 'we need to provide the SCL pin name
Config Sda = Portc.4
'=======================================
'without this you get rubbish on LCD at power up
Home
'=======================================
Locate 1 , 1
Lcd "Test Line 1"
Locate 2 , 1
Lcd "Test Line 2"
End
[/code:1:3b8562a2d8]
↧
BASCOM-AVR Old versions : PIN Change Interrupt BASCOM Version 2.0.7.5 : REPLY
[quote:aac4499212="albertsm"]which processor do you use?
did you checked the PCINT_CHANGE.bas sample from the samples folder?[/quote:aac4499212]
I am using ATMEGA164P
PCINT2 is PORTA, PIN 2, PA2
I went through the sample, here is the code I have written. I do not see any print output from ISR
[code:1:aac4499212]$regfile = "M164pdef.dat"
$crystal = 14745600 'this freq give 0.0% error for all baud rates up to 115200
$baud = 57600
Config Porta = Input
Porta = &HF 'activate pull up
Enable Interrupts 'enable global ints
Enable Pcint2 'we enable pcint0 as this has pcint0-pcint7
On Pcint2 Isr_pcint 'we jump to this label when one of the pins is changed
Pcmsk0 = &B00000100
Do
Loop
Isr_pcint:
Print "Pin change " ; Bin(pcmsk0) ; Spc(3) ; Bin(pina)
'As you see the mask does not change, so to find out which pin changed,
'you need to read the PINB register.
Return
End[/code:1:aac4499212]
↧
↧
BASCOM-AVR Old versions : PIN Change Interrupt BASCOM Version 2.0.7.5 : REPLY
Hello
The following code works.
But I would like to understand why there is no output printed from the ISR as per the code posted before. Thank you for all your help. I am a newbie in coding
[code:1:cd8f45f6ef]$regfile = "M164pdef.dat"
$crystal = 14745600 'this freq give 0.0% error for all baud rates up to 115200
$baud = 57600
Config Porta = Input
Porta = &HF 'activate pull up
Enable Interrupts 'enable global ints
Pcmsk0 = &B00000100
Do
If Pcifr.pcif0 = 1 Then ' change detected
Print "pina.2 has changed" 'in this case it must be pinc.0
Pcifr.pcif0 = 1 ' write a 1 to clear the flag so we can detect it again
End If
Waitms 200
Loop
End[/code:1:cd8f45f6ef]
↧
BASCOM-AVR Old versions : Variable gets zeroed out after Lookupstr : REPLY
Thanks for the help!
Is 2080 available yet?
↧
BASCOM-AVR : Xmega256D3 and TWIE compilation error : REPLY
With a little tinkering i was able to move the BQ32000 I2C RTC to Port.C. And that's working beautifully; with hardware I2C!
The Texas Instruments BQ32000 is very nice to work with. It's largely compatible to the well-known DS1307, but runs of 3.0-3.6V. Furthermore it has a nice correction feature so one can adjust timekeeping from -63 .. +126ppm. It basically skips or adds counts once-in-a-while. It also has a 1Hz or 512Hz output. The 1Hz is affected by the timekeeping adjustment, so it's accurate and can be used well for generating interrupts. The 512Hz option is not adjusted. It can therefore be routed to a frequency counter to determine what the correction should be.
Also it can be backed by a primary- or rechargeable battery or a super capacitor. It has switching an charging circuitry on board.
It's only available as a SMD SOIC-8. (But SOICs are very easy to solder by hand..)
Only one tip: With the XMEGA, do indeed make sure to use 'I2Crepstart' where applicable.
Here's a little sample code. It reads the RTC to variables.
[code:1:095ca6f3b7]Read_RTC:
'Reads time and date from I2C and copy it to system RTC
I2cstart ' Generate start code
I2cwbyte RTCw ' send address
I2cwbyte 0 ' start address in BQ32000
I2crepstart ' Generate start code
I2cwbyte RTCr ' send address
I2crbyte tempb3 , Ack 'seconds
RTC_stop = tempb3 AND &B10000000 'Just D7
RTC_sec = tempb3 AND &B01111111
RTC_sec = Makedec(RTC_sec)
I2crbyte tempb3 , Ack ' minutes
RTC_osc_fail = tempb3 AND &B01111111 'Just D7
RTC_min = tempb3 and &B01111111
RTC_min = Makedec(RTC_min)
I2crbyte tempb3 , Ack ' Hours
RTC_Cent_EN = tempb3 AND &B10000000
RTC_Cent = tempb3 AND &B01000000
RTC_hour = tempb3 AND &B00111111
RTC_hour = Makedec(RTC_hour)
I2crbyte tempb3 , Ack ' Day of Week
RTC_Weekday = tempb3 AND &B00000111 'D7-D3 are and should always remain zero BCD convertion not needed; already binary
I2crbyte tempb3 , Ack ' Day of Month
RTC_day = tempb3 AND &B00111111 'D7-D6 reserved and should remain zero
RTC_day = Makedec(RTC_day)
I2crbyte tempb3 , Ack ' Month of Year
RTC_month = tempb3 AND &B00011111 'D7-D5 reserved and should remain zero
RTC_month = Makedec(RTC_month)
I2crbyte tempb3 , Ack ' Year
RTC_year = Makedec(tempb3)
I2crbyte RTC_CAL_CFG1 , NACK 'Subsequent reading of trickle charge registers is skipped. CAL_CFG1 sets 1Hz/512Hz output and ppm correction
I2cstop
return
[/code:1:095ca6f3b7]
↧
BASCOM-AVR : ATTiny4313/ Interrupt : REPLY
You are right, I agree we don't understand each other very much.
I've just put a print routine in te ISR and set Sol01 to 30 and the printout counted "32" interrupts and "30" for a variable in the "Do...Loop" circle. (Int0= Falling)
Next I'll take a ATtiny 84 and will see how this chip will behave.
I thank you for the support so far and I'll give a message about the final outcome.
↧
↧
BASCOM-AVR : ATTiny4313/ Interrupt : REPLY
[quote:42887ddcd4="2New"]You are right, I agree we don't understand each other very much.[/quote:42887ddcd4]
I'd say, you don't listen and respond attentively.
[quote:42887ddcd4]I've just put a print routine in te ISR and set Sol01 to 30 and the printout counted "32" interrupts and "30" for a variable in the "Do...Loop" circle. (Int0= Falling)[/quote:42887ddcd4]
No, you did not.
If we assume it's above code, only modified by "If Sol01 = 30 Then", it simply won't work, as a falling Int0 can't wake up the controller from PowerDown.
Only Int0/1 in level mode or the PCInt's can do, read the data sheet.
In case you've altered the code some more, i.e. removed "Config Powermode=PowerDown", then my former request applies: show original code.
No more description of code.
[quote:42887ddcd4]Next I'll take a ATtiny 84 and will see how this chip will behave.
I thank you for the support so far and I'll give a message about the final outcome.[/quote:42887ddcd4]
I don't mind, if you're going on hunting mirages, instead of learning how things really work.
You will only hurt yourself.
↧
BASCOM-AVR : Problem with LOOKUP and Word : NEWTOPIC
What is wrong with the below code?
[quote:82ebf8200b]
Dim a as word
Dim index as Byte
Index = 0
Do
a = lookup(index,junkdata)
Print a
incr index
Loop until index = 3
End
JunkData:
Data &H0101
Data &H0102
Data &H0103
[/quote:82ebf8200b]
[b:82ebf8200b][color=red:82ebf8200b](BASCOM-AVR version : 2.0.7.8 )[/b:82ebf8200b][/color:82ebf8200b]
↧
BASCOM-AVR : Problem with LOOKUP and Word : REPLY
Hi,
According the helpfile in the data page:
[quote:3208060be5]Integer and Word constants must end with the %-sign.
Long and Dword constants must end with the &-sign.
Single constants must end with the !-sign.
Double constants must end with the #-sign.
[/quote:3208060be5]
So in your case:
[code:1:3208060be5]
Dim a as word
Dim index as Byte
Index = 0
Do
a = lookup(index,junkdata)
Print a
incr index
Loop until index = 3
End
JunkData:
Data &H0101%
Data &H0102%
Data &H0103%
[/code:1:3208060be5]
↧
BASCOM-AVR : Problem with LOOKUP and Word : REPLY
That did it. Thanks!
↧
↧
AVR : Problems with AVR programmers and windows 10 : REPLY
@ Mark Alberts and all who are concerned:
Most HP laser printers cartridges can be reset to keep printing after the count stops them from printing.
Search for 'how to reset HP laser cartridges' or similar.
Most likely you will find a video on YOUTUBE that explains it.
I have two wireless Brother lasers (HL and MFC types) that had the same issue but can be reset and then print about twice as many pages.
These resets can be done from the control panel.
Some printers cover need to be opened closed and opened again to take the change.
but I think it is worth it when the cost for all cartridges is about 250 to 300 bucks.
Good luck.
Hubert
↧
AVR : Problems with AVR programmers and windows 10 : REPLY
hi Hubert
yes i know about resetting. for my old CD printer i had a device that could reset the chip.
i did not found a way to do that for the HP. But it is of no concern any more. At some stage i bought new toners but it never printed good in color after that. so after the b&w was empty i got rid of it.
The brother works great. and it did not had a problem with printing mostly b&w : i only had to replace the BW toner. And the best of it, the toner cost only 20 euro! not an original one but works the same.
For those in the Netherlands, this can save you a lot of money : [url]https://www.innkt.nl/[/url]
↧
BASCOM-AVR Old versions : PIN Change Interrupt BASCOM Version 2.0.7.5 : REPLY
you need to careful check the registers you used, and their relation to the PINs you use. Then you will understand why it doesnt work.
↧
BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY
Looking at this library I thought why is the address a constant
why is it not a variable
For my first stab at ASM
so I made it one
and it worked!!
But I only have one I2C Lcd module
so I changed the address of the module with the jumper on the back to &H46
Then dimension a variable Pcf8574_loc as byte
then Pcf8574_loc = &H46
So why do this?
We can now have multiple LCDs it is a bus after all !
Ben if you have more than one could you test it!
Regards Paul
↧
↧
BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY
Thanks Paul
Will do a test with more than one I2c LCD.
And publish the result
Have fun
Ben Zijlstra
↧
BASCOM-AVR : scan 8 channel in free runing mode of xmega : NEWTOPIC
Hi
i want to scan 8 channel (pina.0 to pina.7) of xmega32a4 , in unsigned mode, free running mode using interrupts.
i see xmega a manual, xmega a datasheet and help samples, but i see there is just 4 channel for use in free runing mode, is there any way?
thanks
[b:bebbbb6c52][color=red:bebbbb6c52](BASCOM-AVR version : 2.0.7.8 )[/b:bebbbb6c52][/color:bebbbb6c52]
↧
BASCOM-AVR : TIMER1 as Monostable Multivibrator ? : REPLY
Monopulse with timer:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13112
↧