Quantcast
Channel: MCS Electronics Forum
Viewing all 20608 articles
Browse latest View live

BASCOM-AVR : channel numbers in variables : REPLY

$
0
0
[quote:d22b3ff4b3="EDC"]we search for the solutions, we dont search for the troubles[/quote:d22b3ff4b3] Maybe you would doing better by searching for trouble, as in standard Bascom code a Print may contain different variables. This is a special feature of the compiler. These chained variables, including implicit conversions like hex(), can not be forwarded as arguments to a function. This tells: if the TO wants to print anything other than a string, it has to converted to string first. To implement compiler-like behavior into code at each required place will likely cost multiple times the flash and multiple times the efforts of the TOs brute force approach.

BASCOM-AVR : channel numbers in variables : REPLY

$
0
0
HI, I'm the trouble seeker. That's why I get the salary :D :D :D Yes, changing hardware is an option. EDC: yes, sub routines with port selection is an obviously option what in fact need additional execution time and message preparation. The tricky one will be the receiving part on the soft-part. The system uses 4 interrupts, two of them are firing in a wide range, down to about 10ms. But, ok, I see, BASCOM does not handle variables for channel numbers. Regarding timing issues I will spend time to check hardware change options... THX

BASCOM-AVR : channel numbers in variables : REPLY

$
0
0
xmega has variable uart channels. but there are PB versions like 328PB that have 2 uarts. you might check out $serialout and $serialin . you could write some custom code that either handle the HW uart or the SW uart.

Share your working BASCOM-AVR code here : Library for ST7735R display : REPLY

$
0
0
thanks for this useful addition and sharing it.

Share your working BASCOM-AVR code here : Fast library for SSD1963 LCD : REPLY

$
0
0
Hi and thanks for sharing. Last code "Landscape Test SSD1963.bas" dont work propertly witch my LCD: https://www.aliexpress.com/item/7-0-7-inch-800-480-TFT-Touch-LCD-Module-Display-Screen-Panel-with-PCB-Adapter/32916913295.html?spm=a2g0s.9042311.0.0.298e4c4dnceTBr Black screen. But when I program it from this code : https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11500&highlight=ssd1963 LCD display text, but inverted and mirrored...see picture [img:4ceaa72b01]https://www.mcselec.com/userpix/16555_ss_1.jpg[/img:4ceaa72b01] Now when I change initialisation for this: [code:1:4ceaa72b01]Sub Ssd1963_init Cs_disp = 0 'Reset Lcd_res = 1 Waitms 50 Lcd_res = 0 Waitms 50 Lcd_res = 1 Waitms 50 Call Ssd1963_select_reg(&He2) 'PLL multiplier, set PLL clock to 120M Call Ssd1963_write_data(&H0023) 'N=0x36 for 6.5M, 0x23 for 10M crystal Call Ssd1963_write_data(&H0002) Call Ssd1963_write_data(&H0004) Call Ssd1963_select_reg(&He0) 'PLL enable Call Ssd1963_write_data(&H0001) Waitms 1 Call Ssd1963_select_reg(&He0) Call Ssd1963_write_data(&H0003) Waitms 5 Call Ssd1963_select_reg(&H01) 'software reset Waitms 5 Call Ssd1963_select_reg(&He6) 'PLL setting for PCLK, depends on resolution Call Ssd1963_write_data(&H0003) Call Ssd1963_write_data(&H00ff) Call Ssd1963_write_data(&H00ff) Call Ssd1963_select_reg(&Hb0) 'LCD SPECIFICATION Call Ssd1963_write_data(&H0027) Call Ssd1963_write_data(&H0000) Whulp1 = High(hdp) 'Set HDP Call Ssd1963_write_data(whulp1) Whulp1 = Low(hdp) Call Ssd1963_write_data(whulp1) Whulp1 = High(vdp) 'Set VDP Call Ssd1963_write_data(whulp1) Whulp1 = Low(vdp) Call Ssd1963_write_data(whulp1) Call Ssd1963_write_data(&H0000) Call Ssd1963_select_reg(&Hb4) 'HSYNC Whulp1 = High(ht) 'Set HT Call Ssd1963_write_data(whulp1) Whulp1 = Low(ht) Call Ssd1963_write_data(whulp1) Whulp1 = High(hps) 'Set HPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(hps) Call Ssd1963_write_data(hpw) 'Set HPW Whulp1 = High(lps) 'Set LPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(lps) Call Ssd1963_write_data(&H0000) Call Ssd1963_select_reg(&Hb6) 'VSYNC Whulp1 = High(vt) 'Set VT Call Ssd1963_write_data(whulp1) Whulp1 = Low(vt) Call Ssd1963_write_data(whulp1) Whulp1 = High(vps) 'Set VPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(vps) Call Ssd1963_write_data(vpw) 'Set VPW Whulp1 = High(fps) 'Set FPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(fps) Call Ssd1963_select_reg(&Hba) Call Ssd1963_write_data(&H000f) 'GPIO[3:0] out 1 Call Ssd1963_select_reg(&Hb8) Call Ssd1963_write_data(&H0007) 'GPIO3=input, GPIO[2:0]=output Call Ssd1963_write_data(&H0001) 'GPIO0 normal Call Ssd1963_select_reg(&H08) 'rotation - Set the read order from frame buffer to the display panel 'writing from bottom to top 'Call Ssd1963_write_data(&H0000) 'writing from top to bottom Call Ssd1963_write_data(&H0001) 'writing from right to left 'Call Ssd1963_write_data(&H0077) 'Call Ssd1963_write_data(&H0006) Call Ssd1963_select_reg(&Hf0) 'pixel data interface Call Ssd1963_write_data(&H0003) '16-bit (565 format) Waitms 5 Call Ssd1963_select_reg(&H29) 'display on Call Ssd1963_select_reg(&Hd0) Call[/code:1:4ceaa72b01] Ssd1963_write_data(&H000d) Change only this one line (&H36 to &H08): [code:1:4ceaa72b01]Call Ssd1963_select_reg([b]&H08[/b]) 'rotation - Set the read order from frame buffer to the display panel [/code:1:4ceaa72b01] ...LCD display correctly. Next when I copy this initialisation to last code from this subject, LCD start display data, but data is like on this video... https://youtu.be/vz5D1PGGQsA (screen is mirrored) LCD display data only when this part of initialization is like on oryginal code: [code:1:4ceaa72b01]Call Ssd1963_select_reg([b]&H36[/b]) 'rotation - Set the read order from frame buffer to the display panel [/code:1:4ceaa72b01] When &H08 then again black screen. What can I do to display normally? Working mirrored verion below....

BASCOM-AVR : can bus sleep problem : REPLY

$
0
0
Thank you Albert for advice. I replace crystal from 16mhz to 4 mhz and seems ok so far, will test more. I configure fuse to have 14ck startup time without aditional delay but when I measure time from apply vcc and first instruction(set ouput for can transceiver) I have around 4.2 ms. I use Cksel(3-0) 1101 and sut1=0, sut0=1 and 4mhz crystal. Thank you.

BASCOM-AVR : SSD1963 bad colors : NEWTOPIC

$
0
0
Hi, I use last code and library from this post: [url]https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=64606#64606[/url] This is "Fast library for SSD1963 LCD" by Mrshilov. This code "Landscape Test SSD1963.bas" dont work propertly witch my LCD: https://www.aliexpress.com/item/7-0-7-inch-800-480-TFT-Touch-LCD-Module-Display-Screen-Panel-with-PCB-Adapter/32916913295.html?spm=a2g0s.9042311.0.0.298e4c4dnceTBr Black screen. But when I program it from this code : https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11500&highlight=ssd1963 or i Landscape Test SSD1963.bas change initialisation for this: [code:1:61d21f2f5a]Sub Ssd1963_init Cs_disp = 0 'Reset Lcd_res = 1 Waitms 50 Lcd_res = 0 Waitms 50 Lcd_res = 1 Waitms 50 Call Ssd1963_select_reg(&He2) 'PLL multiplier, set PLL clock to 120M Call Ssd1963_write_data(&H0023) 'N=0x36 for 6.5M, 0x23 for 10M crystal Call Ssd1963_write_data(&H0002) Call Ssd1963_write_data(&H0004) Call Ssd1963_select_reg(&He0) 'PLL enable Call Ssd1963_write_data(&H0001) Waitms 1 Call Ssd1963_select_reg(&He0) Call Ssd1963_write_data(&H0003) Waitms 5 Call Ssd1963_select_reg(&H01) 'software reset Waitms 5 Call Ssd1963_select_reg(&He6) 'PLL setting for PCLK, depends on resolution Call Ssd1963_write_data(&H0003) Call Ssd1963_write_data(&H00ff) Call Ssd1963_write_data(&H00ff) Call Ssd1963_select_reg(&Hb0) 'LCD SPECIFICATION Call Ssd1963_write_data(&H0027) Call Ssd1963_write_data(&H0000) Whulp1 = High(hdp) 'Set HDP Call Ssd1963_write_data(whulp1) Whulp1 = Low(hdp) Call Ssd1963_write_data(whulp1) Whulp1 = High(vdp) 'Set VDP Call Ssd1963_write_data(whulp1) Whulp1 = Low(vdp) Call Ssd1963_write_data(whulp1) Call Ssd1963_write_data(&H0000) Call Ssd1963_select_reg(&Hb4) 'HSYNC Whulp1 = High(ht) 'Set HT Call Ssd1963_write_data(whulp1) Whulp1 = Low(ht) Call Ssd1963_write_data(whulp1) Whulp1 = High(hps) 'Set HPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(hps) Call Ssd1963_write_data(hpw) 'Set HPW Whulp1 = High(lps) 'Set LPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(lps) Call Ssd1963_write_data(&H0000) Call Ssd1963_select_reg(&Hb6) 'VSYNC Whulp1 = High(vt) 'Set VT Call Ssd1963_write_data(whulp1) Whulp1 = Low(vt) Call Ssd1963_write_data(whulp1) Whulp1 = High(vps) 'Set VPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(vps) Call Ssd1963_write_data(vpw) 'Set VPW Whulp1 = High(fps) 'Set FPS Call Ssd1963_write_data(whulp1) Whulp1 = Low(fps) Call Ssd1963_select_reg(&Hba) Call Ssd1963_write_data(&H000f) 'GPIO[3:0] out 1 Call Ssd1963_select_reg(&Hb8) Call Ssd1963_write_data(&H0007) 'GPIO3=input, GPIO[2:0]=output Call Ssd1963_write_data(&H0001) 'GPIO0 normal Call Ssd1963_select_reg(&H08) 'rotation - Set the read order from frame buffer to the display panel 'writing from bottom to top 'Call Ssd1963_write_data(&H0000) 'writing from top to bottom Call Ssd1963_write_data(&H0001) 'writing from right to left 'Call Ssd1963_write_data(&H0077) 'Call Ssd1963_write_data(&H0006) Call Ssd1963_select_reg(&Hf0) 'pixel data interface Call Ssd1963_write_data(&H0003) '16-bit (565 format) Waitms 5 Call Ssd1963_select_reg(&H29) 'display on Call Ssd1963_select_reg(&Hd0) Call Ssd1963_write_data(&H000d) End Sub [/code:1:61d21f2f5a] ...LCD display correctly direction and orientation (i test onlu portrait mode), but colors are different. I trying to change bit 3 from register 36 of displays (RGB to BGR) but colors still has wrong, and colors are differend. For example text witch schould be Red is Black :( What can I do more, to LCD colors properly? [b:61d21f2f5a][color=red:61d21f2f5a](BASCOM-AVR version : 2.0.8.1 )[/b:61d21f2f5a][/color:61d21f2f5a]

BASCOM-AVR : Minor increases in duty cycle values : NEWTOPIC

$
0
0
Hi, what can I do, to have minor increases in duty cycle values? (That is a finer adjustment of the duty cycle ...) The code I'm using is as follows: [code:1:628a8ddabc] $regfile = "m1284Pdef.dat" $crystal = 16000000 $baud = 19200 $hwstack = 48 $swstack = 24 $framesize = 48 Dim Dutycycle_tmp As Byte Tccr2a = &B00100011 Tccr2b = &B00001010 'Prescaler 8 Ocr2a = Dutycycle_tmp Pwm2b = 40 '40KHZ [/code:1:628a8ddabc] [b:628a8ddabc][color=red:628a8ddabc](BASCOM-AVR version : 2.0.8.1 )[/b:628a8ddabc][/color:628a8ddabc]

BASCOM-AVR : Minor increases in duty cycle values : REPLY

$
0
0
[quote:367a718250="atmega64"]to have minor increases in duty cycle values? The code I'm using is as follows: [/quote:367a718250]Your code is nonsense. [quote:367a718250="atmega64"][code:1:367a718250]Pwm2b = 40 '40KHZ[/code:1:367a718250][/quote:367a718250]Surely not 40kHz. While I had no fun to disassemble your binary bit-muddle timer2 configuration, I actually had to for finding out that you use mode 7 of timer2, fast pwm with OCR2A as top. Using Dutycycle_tmp to control OCR2A alters thus the frequency, and not duty-cycle at constant frequency. If your code would be nothing else than what you show, then Dutycycle_tmp and OCR2A would be zero. OCR2B has no effect at all, as the timer would always count from 0 to reset at 1, a value of 40 would be never reached. The formula for this timer mode is: f_OCnx = f_clk_I/O / (prescaler * (1 + OCRnx)) ---> f_OC2B = 16MHz / (8 * (1 + 0)) which calculates to 2MHz. If for example OCR2A would be set to the value of 40, the resulting frequency would be 48780Hz, and the duty-cycle could be adjusted with OCR2B within the range of 0 to 40. In case this is to coarse, use a 16bit timer or slow down the main clock, as then a prescaler of 1 would be possible while staying in an 8bit value range. For example, if main clock would be 8MHz, a prescaler of 1 and OCR2A of 199 would result in 40kHz with a 200 step range of duty cycle. Clockdivision = 2 should do the trick with this controller, however everything runs slower then. If such is not desirable, use a prescaler of 8 and OCR2A of 49, you have a 50 step range of duty cycle then. And that's the best you can get then.

BASCOM-AVR : Minor increases in duty cycle values : REPLY

$
0
0
Sorry, you are right... this is the correct code with fixed frequency 40Khz: [code:1:e8915c38b3] Tccr2a = &B00100011 Tccr2b = &B00001010 'Prescaler 8 Ocr2a = 49 '40KHZ Pwm2b = Pwr_pwm_tmp [/code:1:e8915c38b3] and setting PWR_PWM_TMP = 24, I have this signal: [img:e8915c38b3]https://www.mcselec.com/userpix/514_TEK0001_1.jpg[/img:e8915c38b3] I therefore have 48 steps ... [quote:e8915c38b3] For example, if main clock would be 8MHz, a prescaler of 1 and OCR2A of 199 would result in 40kHz with a 200 step range of duty cycle. [/quote:e8915c38b3] would be perfect ... how can I do?

BASCOM-AVR : ATTiny 2313A Timer0 PWM : NEWTOPIC

$
0
0
Hello to all, since i read in the Datasheet that Attiny 2313A Timer0 has PWM functionality, i'm wondering, why i get error message, using the PWM-statement in Bascom? [code:1:5862fb842c] config TIMER0 = Pwm, Prescale = 1, Pwm = 8, Compare A Pwm = Clear Down, Compare B Pwm = Clear Down [/code:1:5862fb842c] Kind regards Norbert [b:5862fb842c][color=red:5862fb842c](BASCOM-AVR version : 2.0.8.1 )[/b:5862fb842c][/color:5862fb842c]

BASCOM-AVR : Minor increases in duty cycle values : REPLY

$
0
0
[quote:96ecddc26e="atmega64"]would be perfect ... how can I do?[/quote:96ecddc26e] As I wrote: slow down the main clock and use a prescaler of 1. [quote:96ecddc26e][b:96ecddc26e]Clockdivision = 2[/b:96ecddc26e] should do the trick with this controller, however [u:96ecddc26e]everything runs slower then.[/u:96ecddc26e][/quote:96ecddc26e]

Share your working BASCOM-AVR code here : Simplest Freq/Duty generator an measure : NEWTOPIC

$
0
0
I really don know why I dont post this simplest method for generate desired square wave. I was think that this is already shared so maybe Im belated... This two codes and schematics enable to generate square wave you want by entering it with keypad..and second code is "complementary" :D It measure but only in designed spectrum.

BASCOM-AVR : Minor increases in duty cycle values : REPLY

$
0
0
Please take a look for something I use and it working fine :D https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewforum&f=8 You use Mega that have two 16 bit timers... thing again.

BASCOM-AVR : Minor increases in duty cycle values : REPLY

$
0
0
[quote:21de356d7f="EDC"]Please take a look for something I use and it working fine[/quote:21de356d7f] The TO already got (imho good) advice in the German forum, where he cross-posted his request. I dislike cross-posting, because it makes double work for helpers, work for which they would think about twice to do, if they would know the TO goes bargaining around with his lack of knowledge. For the solution of this thread the result as follows. Simply use the timer in Bascom's default mode, which is the phase-correct one. Bascom's default timer mode has for some applications the inherent problem, not to achieve the highest possible frequency possible with fast pwm, means this mode is slower by factor 2. What sometimes gets a problem, was required here to get a better resolution. Had the TO done it via Bascom's default timer configuration, he would have finished his problem, without even the requirement to ask. Not sure why the TO kept quite and did not post the result here, maybe he feared it becomes obvious that he did employ more forums at the same time without telling. On the other hand, some users are absolutely self-centered, mine, mine, mine, if only they have their own problem solved, who cares about others. :evil:

Share your working BASCOM-AVR code here : Simplest Freq/Duty generator an measure : REPLY

BASCOM-AVR : ATTiny 2313A Timer0 PWM : REPLY

$
0
0
Simply 8 bit timer not need parameter "Pwm = 8" Remove it and code should compile fine :D

BASCOM-AVR : ATTiny 2313A Timer0 PWM : REPLY

$
0
0
Ok, works fine now, thank you for solving my problem :D :D :D

Share your working BASCOM-AVR code here : nRF24 simple to use, multilink library : REPLY

$
0
0
I am having problems with the multilink library I can get #AN151 working ok It seems to passing an array in a sub I did not think this possible? regards Paul [code:1:b2928ba41c] Sub Set_tx_address(byref Addr_array() As Byte) Reset Ce 'to get access to the registers Tx_bytes(1) = Write_reg + Tx_addr 'TX adress M = Memcopy(addr_array(1) , Tx_bytes(2) , 5) Call W_register(6) End Sub [/code:1:b2928ba41c]

BASCOM-AVR : AtTiny 202 : NEWTOPIC

$
0
0
Hi all. Any support for the AtTiny 202? Or could I use the AtTiny20.dat?? regards svein [b:ca8ccc0514][color=red:ca8ccc0514](BASCOM-AVR version : 2.0.8.1 )[/b:ca8ccc0514][/color:ca8ccc0514]
Viewing all 20608 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>