platformio / platform-intel_mcs51

Intel MCS-51 (8051): development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/intel_mcs51
Apache License 2.0
56 stars 44 forks source link

51 single chip microcomputer is interrupted and cannot be used #28

Closed limhGeek closed 2 years ago

limhGeek commented 4 years ago

`

include

define uchar unsigned char

define LED P1_1

void uart_init(); void uart_tx_string(uchar *str); void uart_tx_byte(uchar str); void Delayms(unsigned int n); uchar rec;

void main() { uart_init(); Delayms(1); uart_tx_string("&26.4$"); while (1) { if (rec == '1') { LED = 1; } else if (rec == '0') { LED = 0; } else if (rec == '2') { LED = !LED; Delayms(50); LED = !LED; Delayms(50); } } }

void uart_timer() interrupt 4 { if (RI) { RI = 0; rec = SBUF; uart_tx_byte('&'); Delayms(2); uart_tx_byte(rec); Delayms(2); uart_tx_byte('$'); } }

void uart_init() { RCAP2L = 0XFD; RCAP2H = 0XFF; T2CON = 0X34; SCON = 0X50; ES = 1; EA = 1; TR1 = 1; }

void uart_tx_byte(uchar str) { SBUF = str; while (!TI) ; }

void uart_tx_string(uchar str) { while (str != '\0') { uart_tx_byte(*str++); Delayms(2); } }

void Delayms(unsigned int n) { unsigned int i, j; for (j = n; j > 0; j--) for (i = 112; i > 0; i--) ; } `

======================= **src\main.c:41: syntax error: token -> 'interrupt' ; column 27 * [.pio\build\stc89c52rc\src\main.rel] Error 1

51 single chip microcomputer interruption can not be used, is not it supported?

pfeerick commented 4 years ago

For starters, looking at your code snippet... void uart_timer() interrupt 4 is not valid hence the main.c:41: syntax error: token -> 'interrupt' ; column 27 error telling you there is something wrong with the code at line 41. However, that may also stem from the core issue... which is:

Without knowing exactly what part you're talking about, it's hard to say... but if it's one of the AT89 series of 51 micros... no, does not appear to be supported. Have a look at https://platformio.org/boards to find out what boards / parts are supported.

zerog2k commented 4 years ago

Looks like you are trying to declare ISRs using the "Keil" way. Take a look at the SDCC user manual. You probably want to declare like this:

void uart1_isr() __interrupt 4
{
...

ref: http://sdcc.sourceforge.net/doc/sdccman.pdf see sec 3.8

zerog2k commented 4 years ago

regarding adding board support, it should be possible to add here: https://github.com/platformio/platform-intel_mcs51/tree/develop/boards

ivankravets commented 2 years ago

Please reopen if you still need help